CSS规则的结构和Grouping、class和id
作者 佚名技术
来源 CSS技术
浏览
发布时间 2012-03-04
2.1 规则的结构
<rules>::=<selector>
<左括号><declarations><右括号>
<declarations>::=
<declaration>{<SEMICOLON><declaration>}[SEMICO
LON]
<SEMICOLON>::=分号
<declaration>::=<property><COLON>
<value>
<COLON>::=冒号
<value>::=<keyword list>
<keyword list>::=<keyword>{<SPACE><keyword>}
<SPACE>::=空格
通常会用空格做为value之间的分隔符,有个例外:
As we''ve seen, CSS keywords are separated by spaces—except in one instance. In the CSS property font, there is exactly one place where a forward-slash (/) can be used to separate two specific keywords. Here''s an example:
h2 {font: large/150% sans-serif;}
The slash separates the keywords that set the element''s font size and line height. This is the only place the slash is allowed to appear in the font declaration. All of the other keywords allowed for font are separated by spaces.
2.1.1 selector
selector: defines which piece of the document will be affected.
Selector通常是html元素,也可能是xml中允许任何元素。
2.1.2 Declarations and Keywords
2.2 Grouping
2.2.1 grouping selectors
将多个元素共用一个style,例子:
/* group 1 */h1 {color: silver; background: white;} h2 {color: silver; background: gray;} h3 {color: white; background: gray;} h4 {color: silver; background: white;} b {color: gray; background: white;} /* group 2 */ h1, h2, h4 {color: silver;} h2, h3 {background: gray;} h1, h4, b {background: white;} h3 {color: white;} b {color: gray;} /* group 3 */ h1, h4 {color: silver; background: white;} h2 {color: silver;} h3 {color: white;} h2, h3 {background: gray;} b {color: gray; background: white;} 2.2.1.1 The universal selector * {color: red;} 2.2.2 grouping declarations 例子: h1 {font: 18px Hel |
凌众科技专业提供服务器租用、服务器托管、企业邮局、虚拟主机等服务,公司网站:http://www.lingzhong.cn 为了给广大客户了解更多的技术信息,本技术文章收集来源于网络,凌众科技尊重文章作者的版权,如果有涉及你的版权有必要删除你的文章,请和我们联系。以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢! |
你可能对下面的文章感兴趣
关于CSS规则的结构和Grouping、class和id的所有评论