Home Web Front-end CSS Tutorial css tutorial css and document_experience exchange

css tutorial css and document_experience exchange

May 16, 2016 pm 12:05 PM
css document

Cascading Style Sheets: The Definitive Guide, 2nd Edition is a thorough review of all aspects of CSS2.1 and a comprehensive guide to CSS implementation. The book includes new content on positioning, lists and generated content, table layout, user interface, paged media, and more. It explores in detail each individual CSS property and how it interacts with other properties, and shows how to avoid common mistakes in interpretation.
 
W3cCss主页:
http://www.w3.org/Style/CSS/
1 css和document
1.1 elements
html中的元素很容易辨识,如p,table,span,a,div。
xml中元素由dtd定义,或者xml schema定义。每个元素部分代表了其表现方式。
Css中可以看作每个元素产生一个box,该box包含了元素的内容。
1.1.1元素类型:replaced和nonreplaced elements,block-level和inline-level elements
replaced elements:元素的内容可以被不是直接由文档表示的内容替换。典型的是xhtml中的img,它可以被指向文档外部的图片文件代替。
    Input元素也可以根据其type的不同,而被radio button,checkbox,text input box代替。
    Replaced elements也在显示时产生一个box。
Nonreplaced elements:html和xhtml的大多数元素是nonreplaced。就是说,这些元素的内容由用户代理(user agent,通常是指浏览器)在元素产生的box中来表述present。(box是不是指元素对应在页面上的一个region?)。
    比如hi there是nonreplaced,文本hi here将由user agent
来显示。
 
Block-level element块元素:产生一个元素box,该box填充其父元素的内容区域,并且其两边没有其他元素。就是说在默认的情况下每个block-level都是单独一行的。比如p,div。
list items是一种特殊的块元素。为了跟其他块元素具有统一的行为,为无序的lists产生一个符号,如bullet;为有序的lists产生一个数字。将符号或数字加到元素box上。除了符号的表现方式外,其他特性跟其余的块元素一样。
Inline-level element内联元素:产生一个元素box,其中是一行文本,并且不是单独一行的。
典型的例子是xhtml中的a元素,另外如strong,em。因为内联元素不会打断其前后的
显示,所以内联元素出现在其他元素中的话不会打断其他元素的显示。
 
注意:xhtml和html中块元素不能从内联元素继承,但是css中没有类似规定。没有限制元素嵌套方式。

Block element (block element) is generally a container element for other elements. Block elements generally start on a new line and can accommodate inline elements and other block elements.A common block element is the paragraph tag 'P. "form"This block element is special. It can only be used to accommodate other block elements.

If there is no effect of css , the block elements will be sequentially arranged one line at a time. With css, we can change the default layout mode of html and place the block elements where you want . Instead of stupidly starting a new line every time. It should be pointed out that the table tag is also a type of block element. table based layout and css based layout are common to ordinary users (excluding eyesight). From the perspective of people with disabilities, blind people, etc.), there is no other difference between the two layouts except the difference in page loading speed. However, if an ordinary user inadvertently clicks the View page source code button, the difference between the two will be very large. The css layout page source code designed based on the concept of good reconstruction can at least allow ordinary users without web development experience to convert content quickly Read it. From this perspective, css layout code should have a better aesthetic experience.

You can think of the block container element div as boxes , or if you It will be easier to understand if you have played Cut and Paste. We first cut out the necessary articles from various newspapers and magazines. The cut content of each block is a block. Then we glued these pieces of paper onto a new piece of blank paper according to our layout intention. This will form your own unique digest . As an extension of the technology, web layout design follows the same pattern. .

Inline elements(inline element) are generally based on semantic level (semantic )'s basic element. Inline elements can only accommodate text or other inline elements. The common inline element "a".

Both block element and inline element Concepts in the html specification. The basic difference between block elements and inline elements is that block elements generally start on a new line. And when css control is added, this attribute difference between block elements and inline elements does not become a difference. For example, we can add the attribute display:block to the inline element cite, so that it also has the attribute of starting from a new line every time.

The basic concept of variable elements is that it needs to determine whether the element is a block element or an inline element based on the context.Variable elements still belong to the above two element categories. Once the context determines its category, it must follow the rules of block elements or inline elements. See full text for rough element classification.

ps:About the Chinese name of inline element, there are many inline elements , inline elements, inline elements, and inline elements. Basically there is no unified translation, just call it whatever you want. In addition, when it comes to inline elements, we will think of display whose attribute is display:inline;This attribute can repair the famous IE SPAN>Double floating boundary problem.

块元素(block element)
* address - 地址
* blockquote - 块引用
* center - 举中对齐块
* dir - 目录列表
* div - 常用块级容易,也是css layout的主要标签
* dl - 定义列表
* fieldset - form控制组
* form - 交互表单
* h1 - 大标题
* h2 - 副标题
* h3 - 3级标题
* h4 - 4级标题
* h5 - 5级标题
* h6 - 6级标题
* hr - 水平分隔线
* isindex - input prompt
* menu -
菜单列表
* noframes - frames可选内容,(对于不支持frame的浏览器显示此区块内容
* noscript - )可选脚本内容(对于不支持script的浏览器显示此内容)
* ol - 排序表单
* p - 段落
* pre - 格式化文本
* table - 表格
* ul - 非排序列表

内联元素(inline element)
* a - 锚点
* abbr - 缩写
* acronym - 首字
* b - 粗体(不推荐)
* bdo - bidi override
* big -
大字体
* br - 换行
* cite - 引用
* code - 计算机代码(在引用源码的时候需要)
* dfn - 定义字段
* em - 强调
* font - 字体设定(不推荐)
* i - 斜体
* img - 图片
* input - 输入框
* kbd - 定义键盘文本
* label - 表格标签
* q - 短引用
* s - 中划线(不推荐)
* samp - 定义范例计算机代码
* select - 项目选择
* small - 小字体文本
* span - 常用内联容器,定义文本内区块
* strike - 中划线
* strong - 粗体强调
* sub - 下标
* sup - 上标
* textarea - 多行文本输入框
* tt - 电传文本

* u - 下划线
* var - 定义变量

可变元素
可变元素为根据上下文语境决定该元素为块元素或者内联元素。
* applet - java applet
* button -
按钮
* del - 删除文本
* iframe - inline frame
* ins -
插入的文本
* map - 图片区块(map)
* object - object对象
* script - 客户端脚本

一个例子:
<span style="FONT-SIZE: 10.5pt"></span>
Copy after login
Copy after login
Copy after login
Copy after login
<span style="FONT-SIZE: 10.5pt"><p>This is a paragraph with <em>an inline element</em> within it.</p></span>
Copy after login
<span style="FONT-SIZE: 10.5pt"></span>
Copy after login
Copy after login
Copy after login
Copy after login
上例中有两个块元素,p和body,一个内联元素em。
在xhtml中em可以从p继承,反之不行。在xhtml中内联元素可以从块元素继承而来,反之不行。
在css中没有这样的规定,css可以改变上例的结构。
p {display: inline;}
 
em {display: block;}
在inline box中插入block box。效果:
改变元素的显示角色在xhtml中很有用。Xml文档没有任何的继承的显示角色,因此通过css来定义就相当重要。
<span style="FONT-SIZE: 10.5pt"><book></book></span>
Copy after login
Copy after login
<span style="FONT-SIZE: 10.5pt"> <maintitle>Cascading Style Sheets: The Definitive Guide</maintitle></span>
Copy after login
<span style="FONT-SIZE: 10.5pt"> <subtitle>Second Edition</subtitle></span>
Copy after login
<span style="FONT-SIZE: 10.5pt"> <author>Eric A. Meyer</author></span>
Copy after login
Copy after login
<span style="FONT-SIZE: 10.5pt"> <publisher>O'Reilly and Associates</publisher></span>
Copy after login
Copy after login
<span style="FONT-SIZE: 10.5pt"> <pubdate>2004</pubdate></span>
Copy after login
Copy after login
<span style="FONT-SIZE: 10.5pt"> <isbn>blahblahblah</isbn></span>
Copy after login
Copy after login
<span style="FONT-SIZE: 10.5pt"></span>
Copy after login
Copy after login
Copy after login
Copy after login
<span style="FONT-SIZE: 10.5pt"><book></book></span>
Copy after login
Copy after login
<span style="FONT-SIZE: 10.5pt"> <maintitle>CSS2 Pocket Reference</maintitle></span>
Copy after login
<span style="FONT-SIZE: 10.5pt"> <author>Eric A. Meyer</author></span>
Copy after login
Copy after login
<span style="FONT-SIZE: 10.5pt"> <publisher>O'Reilly and Associates</publisher></span>
Copy after login
Copy after login
<span style="FONT-SIZE: 10.5pt"> <pubdate>2004</pubdate></span>
Copy after login
Copy after login
<span style="FONT-SIZE: 10.5pt"> <isbn>blahblahblah</isbn></span>
Copy after login
Copy after login
<span style="FONT-SIZE: 10.5pt"></span>
Copy after login
Copy after login
Copy after login
Copy after login
<span style="FONT-SIZE: 10.5pt">默认的显示:</span>
Copy after login
<span>
 <img src="/static/imghw/default1.png" data-src="http://www.webjx.com/files/allimg/080827/0125162.png" class="lazy" alt=""></span>
Copy after login
<span style="FONT-SIZE: 10.5pt">用</span><span style="FONT-SIZE: 10.5pt">css</span><span style="FONT-SIZE: 10.5pt">来定义显示层次:</span>
Copy after login
<span style="FONT-SIZE: 10.5pt">book, maintitle, subtitle, author, isbn {display: block;}</span>
Copy after login
<span style="FONT-SIZE: 10.5pt">publisher, pubdate {display: inline;}</span>
Copy after login
<span style="FONT-SIZE: 10.5pt">现在显示:</span>
Copy after login
<span>
 <img src="/static/imghw/default1.png" data-src="http://www.webjx.com/files/allimg/080827/0125163.png" class="lazy" alt=""></span>
Copy after login
 
能够影响显示角色display roles 的特性是css在多种情况下高度有用的重要原因。
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to use bootstrap button How to use bootstrap button Apr 07, 2025 pm 03:09 PM

How to use the Bootstrap button? Introduce Bootstrap CSS to create button elements and add Bootstrap button class to add button text

How to resize bootstrap How to resize bootstrap Apr 07, 2025 pm 03:18 PM

To adjust the size of elements in Bootstrap, you can use the dimension class, which includes: adjusting width: .col-, .w-, .mw-adjust height: .h-, .min-h-, .max-h-

How to insert pictures on bootstrap How to insert pictures on bootstrap Apr 07, 2025 pm 03:30 PM

There are several ways to insert images in Bootstrap: insert images directly, using the HTML img tag. With the Bootstrap image component, you can provide responsive images and more styles. Set the image size, use the img-fluid class to make the image adaptable. Set the border, using the img-bordered class. Set the rounded corners and use the img-rounded class. Set the shadow, use the shadow class. Resize and position the image, using CSS style. Using the background image, use the background-image CSS property.

How to upload files on bootstrap How to upload files on bootstrap Apr 07, 2025 pm 01:09 PM

The file upload function can be implemented through Bootstrap. The steps are as follows: introduce Bootstrap CSS and JavaScript files; create file input fields; create file upload buttons; handle file uploads (using FormData to collect data and then send to the server); custom style (optional).

How to remove the default style in Bootstrap list? How to remove the default style in Bootstrap list? Apr 07, 2025 am 10:18 AM

The default style of the Bootstrap list can be removed with CSS override. Use more specific CSS rules and selectors, follow the "proximity principle" and "weight principle", overriding the Bootstrap default style. To avoid style conflicts, more targeted selectors can be used. If the override is unsuccessful, adjust the weight of the custom CSS. At the same time, pay attention to performance optimization, avoid overuse of !important, and write concise and efficient CSS code.

How to verify bootstrap date How to verify bootstrap date Apr 07, 2025 pm 03:06 PM

To verify dates in Bootstrap, follow these steps: Introduce the required scripts and styles; initialize the date selector component; set the data-bv-date attribute to enable verification; configure verification rules (such as date formats, error messages, etc.); integrate the Bootstrap verification framework and automatically verify date input when form is submitted.

How to view the date of bootstrap How to view the date of bootstrap Apr 07, 2025 pm 03:03 PM

Answer: You can use the date picker component of Bootstrap to view dates in the page. Steps: Introduce the Bootstrap framework. Create a date selector input box in HTML. Bootstrap will automatically add styles to the selector. Use JavaScript to get the selected date.

How to set up the framework for bootstrap How to set up the framework for bootstrap Apr 07, 2025 pm 03:27 PM

To set up the Bootstrap framework, you need to follow these steps: 1. Reference the Bootstrap file via CDN; 2. Download and host the file on your own server; 3. Include the Bootstrap file in HTML; 4. Compile Sass/Less as needed; 5. Import a custom file (optional). Once setup is complete, you can use Bootstrap's grid systems, components, and styles to create responsive websites and applications.

See all articles