css中可以和不可以繼承的屬性

來源:互聯網
上載者:User

標籤:

不可繼承的:

1 display、margin、border、padding、background2 height、min-height、max- height3 width、min-width、max-width、overflow4 position、left、right、top、 bottom、z-index5 float、clear、table-layout、vertical-align6 page-break-after、 page-bread-before和unicode-bidi

不可繼承:也就是指子節點不能繼承父節點的屬性

簡單舉例:

1 <div style="border: 1px solid #000;">2     父節點3     <p>這是子節點</p>4 </div>

:

 

如果子節點能繼承父節點的border屬性,那麼也會有一個紅色邊框。

所有元素可繼承:

visibility和cursor

內嵌元素可繼承:
letter-spacing、word-spacing、white-space、line-height、color
font、font-family、font-size、font-style、font-variant、font-weight
text- decoration、text-transform、direction

塊狀元素可繼承:

text-indent和text-align

列表元素可繼承:

list-style、list-style-type、list-style-position、list-style-image

表格元素可繼承:

border-collapse
相反,可繼承就是父節點設定了這個屬性後,子節點就可以繼承他的屬性,

權重的比較:

標籤選取器(1)<類別選取器(10)<id選取器(100)<行內樣式<!important


因而它有更高的權重。當有多個規則都能應用於同一個元素時,權重越高的樣式將被優先採用。而繼承
屬性的特性值為0;也就是說,任何一條與css繼承值衝突的屬性值都會覆蓋繼承的屬性值!!!

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.