css中list-style:none為什麼不起作用?

來源:互聯網
上載者:User
代碼見下面?為什麼list-style:none不起作用呀?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>無標題文檔</title><style type="text/css">    body{        list-style:none;    }</style> </head> <body>    <ul>        <li>            aaaaaa        </li>        <li>            bbbbbb        </li>    </ul></body></html>

沒ul 的預設等級高。

為何要設在body上?

你設定在body上面,那麼之後的ul之內是去繼承這個body的設定,繼承來的東西,會被本身攜帶的屬性覆蓋的。

好複雜的問題~
可不可以這樣理解:
ul的預設樣式屬於內聯樣式表
head標籤中的 body{……},屬於內部樣式表
而 內部樣式表 的優先順序要低於 內聯樣式表

如果沒反映的話 最好就加在div裡的css style 裡這樣最穩定了

寫在body上理論上是可以被body裡面的元素繼承,但是在CSS裡繼承的許可權是最低的,所以會被UL自身的預設樣式覆蓋,這樣的代碼一般都直接寫給UL

ul{        list-style:none;    }
相關文章

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.