css 選取器分類總結

來源:互聯網
上載者:User

標籤:html   css   屬性   css選取器   

css 選取器分為以下四種:

1,html元素選取器

以html元素標籤名字顯示

body{bgcolor:green;}p{color: red;}

2,id 選取器


id 選取器可以為標有特定 id 的 HTML 元素指定特定的樣式。

id 選取器以 "#" 來定義。在html主題中,id屬性值始終是唯一的

<p id="red">這個段落是紅色。</p><p id="green">這個段落是綠色。</p>#red{color:red;}#green {color:green;}

3 ,class類別選取器

class選取器,以點(.)顯示

<p class="center">This paragraph will also be center-aligned.</p>.center {text-align: center;}

4,派生選取器,(html,id,class屬性,都有派生選取器)

li strong {    font-style: italic;    font-weight: normal;  } .center strong{    font-style: italic;    font-weight: normal;  }


本文出自 “crazy_sir” 部落格,請務必保留此出處http://douya.blog.51cto.com/6173221/1840831

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.