快速业务通道

CSS规则的结构和Grouping、class和id

作者 佚名技术 来源 CSS技术 浏览 发布时间 2012-03-04
vetica;}   h1 {color: purple;}   h1 {background: aqua;} h1 {    font: 18px Helvetica;    color: purple;    background: aqua;   } If the second semicolon is omitted, however, the user agent will interpret the style sheet as follows: h1 {    font: 18px Helvetica;    color: purple background: aqua;   } Since background: is not a valid value for color, and also since color can be given only one keyword, a user agent will ignore the color declaration (including the background: aqua part) entirely. It might render h1s as purple text without an aqua background, but more likely, you won''t even get purple h1s. Instead, they''ll be the default color (usually black) with no background at all. (The declaration font: 18px Helvetica will still take effect since it was correctly terminated with a semicolon.) 2.2.3 Grouping Everything 就是同时group selector和declaration h1, h2, h3, h4, h5, h6 {color: gray; background: white; padding: 0.5em;    border: 1px solid black;}   You''ve grouped the selectors, so the styles on the right side of the rule will be applied to all the headings listed, and grouping the declarations means that all of the listed styles will be applied to the selectors on the left side of the rule. 2.3 class and id selectors 最简单的selector是只针对文档元素的element selecoter,还有两种selecotrs:class selectors和id selectors。 这两种selector可以独立于文档元素的,即不是于具体某个的文档元素直接关联的。这两种selecoter可以单独使用,也可以和element selector一起使用。但是这两种selector的使用需要配合文档编写的规范性。 比如写一个讨论plutonium处理方式的文档,文档由很多段组成,包含很多警告信息,希望将警告的字体置为bold,以突出显示。但是这些警告信息的格式很多,一段文字,列表式,一小节文本等。所以不能通过 p {font-weight: bold;} 的形式来定义。这样无法从全是文本的整个文档中找到警告信息,并加粗。 因此,解决方式:使用class selectors给警告信息的部分加上标记。

凌众科技专业提供服务器租用、服务器托管、企业邮局、虚拟主机等服务,公司网站:http://www.lingzhong.cn 为了给广大客户了解更多的技术信息,本技术文章收集来源于网络,凌众科技尊重文章作者的版权,如果有涉及你的版权有必要删除你的文章,请和我们联系。以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!

分享到: 更多

Copyright ©1999-2011 厦门凌众科技有限公司 厦门优通互联科技开发有限公司 All rights reserved

地址(ADD):厦门软件园二期望海路63号701E(东南融通旁) 邮编(ZIP):361008

电话:0592-5908028 传真:0592-5908039 咨询信箱:web@lingzhong.cn 咨询OICQ:173723134

《中华人民共和国增值电信业务经营许可证》闽B2-20100024  ICP备案:闽ICP备05037997号