Heim  >  Artikel  >  Web-Frontend  >  CSS基础学习六:id选择器_html/css_WEB-ITnose

CSS基础学习六:id选择器_html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 11:34:072155Durchsuche

        一id选择器示例

        id选择器允许以一种独立于文档元素的方式来指定样式。在某些方面,id选择器类似于类选择器,不过也有一些

重要差别。

       语法

       首先,id选择器前面有一个 # 号,也称为棋盘号或井号。

       请看下面的规则:

<span style="font-size:18px;">*#intro { font-size:24px;background-color:#000000;color:#FF0000;}</span>
       与类选择器一样,id选择器中可以忽略通配选择器。前面的例子也可以写作:

<span style="font-size:18px;">#intro { font-size:24px;background-color:#000000;color:#FF0000;} </span>

       这个选择器的效果将是一样的。

       第二个区别是id选择器不引用 class 属性的值,毫无疑问,它要引用 id 属性中的值。

       以下是一个实际id选择器的例子:

<span style="font-size:18px;"><meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title></title></span>
Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn