


Proficient in CSS DIV web page style and layout CSS_html/css_WEB-ITnose
CSS, the English name is Cascading Style Sheet, and the Chinese name is Cascading Style Sheet, is a markup language used to control page styles and allow the separation of style information from web content. DIV CSS is a WEB design standard. It is a The layout method of web pages. Different from the traditional way of positioning through table layout, it can realize the separation of web page content and presentation. When it comes to DIV CSS combination, we have to start with XHTML. XHTML is a new language optimized and improved on the basis of HTML (a subset of the Standard Universal Markup Language). It aims to adapt to more needs of future network applications based on XML applications and powerful data conversion capabilities. "DIV CSS" is actually a misnomer, and the standard name should be XHTML CSS. Because DIV and Table are both tags in XHTML or HTML language, and CSS is just a form of expression.
Next, the editor will start with the most basic CSS.DIV web page style and layout, slowly introduce it, go in depth bit by bit, and then analyze it slowly with examples, hoping it will be helpful to everyone. Usually when we learn CSS, we should try our best to refer to other websites when writing CSS. For example, Baidu, Google, etc., by learning the CSS code of other websites, you can quickly get a different feel for the page design, and it is easier to get started. We call this "standing on the shoulders of giants." Today I will briefly introduce the basic concepts of CSS and the basic syntax of CSS. First, let's look at a picture:
Next, the editor will follow the context of this picture and gradually increase the basic knowledge of CSS.
A first look at CSS
Concept: CSS (Cascading Style Sheet), translated into Chinese as Cascading Style Sheet, is used to control web page styles and allow A markup language that separates style information from web page content.
Use CSS to control the page: There are four ways to control the page with CSS: inline style, inline style, link style and imported style. For slightly larger web pages, we will use the link style because it separates HTML and CSS to facilitate later maintenance and is clear and clear.
Basic syntax
For CSS selectors, that is, which html objects we select for CSS style control, there are three types: tag selectors, category selectors and ID selector, next, the editor will introduce these three selectors in detail.
Tag selector:
Let’s look at an example code and its display:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312" /><title>Untitled Document</title><style type="text/css">h1{color:#0000FF;font-size:40px;}</style></head><body><h1>CSS选择器</h1><h1>CSS选择器</h1></body></html>
The effect is as follows:
Category selector: Let’s continue talking about the category selector: which is what we often call .class.
Comparing the tag selector above, we can easily see that only h1 has become .class; no other changes can be seen, so let’s see how to apply it in the code. Let’s take a look at an example code and its display effect:
<html><head><title>class选择器</title><style type="text/css"><!--.one{ color:red; /* 红色 */ font-size:18px; /* 文字大小 */}.two{ color:green; /* 绿色 */ font-size:20px; /* 文字大小 */}.three{ color:cyan; /* 青色 */ font-size:22px; /* 文字大小 */}--></style> </head><body> <p class="one">class选择器1</p> <p class="two">class选择器2</p> <p class="three">class选择器3</p> <h3 class="two">h3同样适用</h3></body></html>
We can see that this h3 and .two have the same effect, but The fonts are different, that is the difference between h3's default font and class. The advantage of using class is that it allows users to fully customize and this class can be used repeatedly. This is what our p mark and h3 mark show.
ID Selector
Let’s take a look at an example code and its display:
<html><head><title>ID选择器</title><style type="text/css"><!--#one{ font-weight:bold; /* 粗体 */}#two{ font-size:30px; /* 字体大小 */ color:#009900; /* 颜色 */}--></style> </head><body> <p id="one">ID选择器1</p> <p id="two">ID选择器2</p> <p id="two">ID选择器3</p> <p id="one two">ID选择器3</p></body></html>
CSS declarations
There are three types of CSS declarations, collective declarations, global declarations and nested declarations. Take a look at the following two examples:
<html><head><title>集体声明</title><style type="text/css"><!--h1, h2, h3, h4, h5, p{ /* 集体声明 */ color:purple; /* 文字颜色 */ font-size:15px; /* 字体大小 */}h2.special, .special, #one{ /* 集体声明 */ text-decoration:underline; /* 下划线 */}--></style> </head><body> <h1>集体声明h1</h1> <h2 class="special">集体声明h2</h2> <h3>集体声明h3</h3> <h4>集体声明h4</h4> <h5>集体声明h5</h5> <p>集体声明p1</p> <p class="special">集体声明p2</p> <p id="one">集体声明p3</p></body></html>
The following example is a nested statement, which can help us find the area we want to control very accurately:
<html><head><title>CSS选择器的嵌套声明</title><style type="text/css"><!--p b{ /* 嵌套声明 */ color:maroon; /* 颜色 */ text-decoration:underline; /* 下划线 */}--></style> </head><body> <p>嵌套使<b>用CSS</b>标记的方法</p> 嵌套之外的<b>标记</b>不生效</body></html>
CSS inheritance, please click for details. Let’s take a look at the code and running effect of an example:
Message from the editor: In this blog post, the editor mainly introduces some basic knowledge of CSS. Generally speaking, the introduction is divided into two parts, one is a preliminary exploration of CSS, and the other is the basic syntax of CSS. , a preliminary exploration of CSS including concepts and using CSS to control pages. The basic syntax of CSS includes three aspects, namely CSS selectors, CSS declarations, and CSS inheritance. With CSS, our interface instantly comes alive and moves, making our Internet world more colorful and infinitely beautiful. BS learning, unfinished, to be continued...

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

HTML is suitable for beginners because it is simple and easy to learn and can quickly see results. 1) The learning curve of HTML is smooth and easy to get started. 2) Just master the basic tags to start creating web pages. 3) High flexibility and can be used in combination with CSS and JavaScript. 4) Rich learning resources and modern tools support the learning process.

HTML defines the web structure, CSS is responsible for style and layout, and JavaScript gives dynamic interaction. The three perform their duties in web development and jointly build a colorful website.

WebdevelopmentreliesonHTML,CSS,andJavaScript:1)HTMLstructurescontent,2)CSSstylesit,and3)JavaScriptaddsinteractivity,formingthebasisofmodernwebexperiences.

GiteePages static website deployment failed: 404 error troubleshooting and resolution when using Gitee...

AnexampleofastartingtaginHTMLis,whichbeginsaparagraph.StartingtagsareessentialinHTMLastheyinitiateelements,definetheirtypes,andarecrucialforstructuringwebpagesandconstructingtheDOM.

To achieve the effect of scattering and enlarging the surrounding images after clicking on the image, many web designs need to achieve an interactive effect: click on a certain image to make the surrounding...

HTML, CSS and JavaScript are the three pillars of web development. 1. HTML defines the web page structure and uses tags such as, etc. 2. CSS controls the web page style, using selectors and attributes such as color, font-size, etc. 3. JavaScript realizes dynamic effects and interaction, through event monitoring and DOM operations.

The Y-axis position adaptive algorithm for web annotation function This article will explore how to implement annotation functions similar to Word documents, especially how to deal with the interval between annotations...
