CSS屬性選擇符

來源:互聯網
上載者:User

標籤:

屬性選擇符:

E[att]      選擇具有att屬性的E元素。

<style type="text/css">a[class]{ background-color: red;}</style><body><a href="" class="a">連結a</a><a href="" id="b">連結b</a></body>

 

E[att="val"]    選擇具有att屬性且屬性值等於valu的E元素。

<style type="text/css">a[class="1"]{ background-color: red;}</style><body><a href=""  class="1">連結a</a><a href=""  class="2">連結b</a></body>

 

E[att~="val"]    選擇具有att屬性且屬性值為一用空格分隔的字詞列表,其中一個等於val的E元素。

<style>a[class~="id"]{color: red;}</style><body><ul><li><a href="" class="id 1">連結a</a></li><li><a href="" class="1">連結b</a></li><li><a href="" class="1">連結b</a></li></body>

 

E[att^="val"]    選擇具有att屬性且屬性值為以val開頭的字串的E元素。

<style>a[title~="163"]{color:red;}</style><body><a href="http://www.163.com/" title="www 163 com">紅色</a><a href="http://www.baidu.com/" title="www baidu com">紅色</a></body>

E[att$="val"]    選擇具有att屬性且屬性值為以val結尾的字串的E元素。

<style>li[class$="a"] {color: #f00;}</style></head><body><ul><li class="abc">清單項目</li><li class="acb">清單項目</li></ul></body>

E[att*="val"]    選擇具有att屬性且屬性值為包含val的字串的E元素。

<style type="text/css">a[href*=".html"]{color:red;}a[href*=".php"]{color:green;}a[href*=".jsp"]{color:blue;}</style><body><a href="http://www.dreamdu.com/css.html?id=1&name=www">夢之都紅色字型</a><a href="http://www.dreamdu.com/css.php?id=2&name=dreamdu">夢之都綠色字型</a><a href="http://www.dreamdu.com/css.jsp?id=3&name=com">夢之都藍色字型</a></body>

E[att|="val"]    選擇具有att屬性且屬性值為以val開頭並用串連符"-"分隔的字串的E元素。 

<style type="text/css">a[title~="dreamdu"]{color:red;}</style><body><a href="http://www.dreamdu.com/" title="www dreamdu com">紅色</a></body>

font-family,font-size,font-weight,font-style

<style type="text/css">p { font-family: "宋體";}h1 { font-size:14px ;}h2 { font-weight: normal ;}h3 {font-style: italic;}</style></head><body><p>這是一個標籤</p><h1>這是一個標籤</h1><h2>這是一個標籤</h2><h3>這是一個標籤</h3></body>

 

font(字型樣式縮寫)

<style type="text/css">/*p{font-style:italic;font-weight:bold;font-size:14px;line-height:22px;font-family:宋體;}*/p {font:italic bold 14px/22px 宋體}</style></head><body><p>這是一個標籤</p></body></html> 

 

 

text-decoration(文本裝飾線條),text-shadow(文字陰影)

<style type="text/css">p { text-decoration: underline;text-shadow: 2px 2px #ff0000; }</style></head><body><p>這是一個標籤</p></body>

 

width,height

 

<style type="text/css">p { width:300px;}div { height:100px; padding: 1px; border:1px solid;}</style></head><body><p>這是一個標籤這是一個標籤這是一個標籤這是一個標籤</p><div>這是一個標籤</div></body>

 

 

 

CSS屬性選擇符

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.