css tutorial css and document_experience exchange

WBOY
Release: 2016-05-16 12:05:00
Original
1235 people have browsed it
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 alt="" src="http://www.webjx.com/files/allimg/080827/0125162.png"></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 alt="" src="http://www.webjx.com/files/allimg/080827/0125163.png"></span>
Copy after login
 
能够影响显示角色display roles 的特性是css在多种情况下高度有用的重要原因。
Related labels:
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!