Heim  >  Artikel  >  Web-Frontend  >  CSS语言笔记<一>_html/css_WEB-ITnose

CSS语言笔记<一>_html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 11:46:531028Durchsuche

CSS ( Cascading Style Sheets ) 中文:层叠样式表

定于语法:

实例:

<style type="text/css">a{  color:red;  text-align:center;  font-size:24px; }</style>

选择器

id选择器

HTML标签属性是以id来设定选择器,在CSS中就以“#”来选定。

如:一段文字

以下为选定表示的方法。
实例:

<style type="text/css">#a{  color:red;  text-align:center;  font-size:24px;    }</style>

class选择器

如果是以class选择器,表示的写法是以“.”号,和id选择器不一样的是,class选择器可以在多个HTML标签中使用。

如:一段文字

   

一段文字

实例:

<style type="text/css">.qqq{    color:red;    text-align:center;    font-size:24px;        }</style>

第二种写法,表示a标签下的qqq元素

<style type="text/css">a.qqq{   color:red;   text-align:center;   font-size:24px;       }</style>

多元素选择器

实例:

<style type="text/css">a,b,c,d{        color:#FFFFFF;        text-align:center;        font-size:24px;        }</style>

后代元素选择器

选择实例中a下的li元素,后代元素用空格来选择。

实例:

<style type="text/css">.a li{       color:red;      }</style>

子元素选择器

子元素就是class下中同样的元素,父子级关系。用大于号表示

实例:

<style type="text/css">.a > .title{                color:#FF6300               }</style>

 

 

 

总结

id具有唯一性,class具有多用性。

 

待续.............

 

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