专注优质Wordpress企业网站搭建与优化

开宗明义:《CSS权威指南第三版》精髓中文学习笔记【4.9】CSS中的ID选择符



SEO优化,CSS教程,Wordpress博客 - 来自西米CC(http://ximicc.com)在很多方面,ID选择符都类似于类选择符——但也有一些重要的区别。第一个区别就是ID选择符的前面是#号——而不是句点。看看下面的这条规则:

  1. #first-para {font-weight:bold;}

这会使任何lD属性的值为first-para的元素样式为粗体文本。这就是第一个区别:ID选择符指向的是ID属性中的值,而不是引用类属性的值。下面是一个ID选择符的实例:

  1. #first-para {font-weight:bold;}
  2. <p id="first-para">ximicc is a website about CSS design ,include examples in CSS gallery, CSS beauty, CSS tutorials, CSS news, jobs and the latest from the web design standards community. Welcome to ximicc.com .</p>
  3.  
  4. Learn the basics of CSS design in ximicc.com . Positioning and the formatting of link text is covered.You also can download free Website templates, CSS Templates, Blogger Templates .

如图所示,段落中的文本显示正如上面所描写的那样第一段为粗体,而第二段不是:

CSS中的ID选择符

注意first-para值并不局限于某个段落,它可以分配给文档中的任何元素。

[ 以下内容您也可能感兴趣 ]

Add a Comment