day3 css核心属性

2018-12-07  本文已影响0人  遇见那天的雨真大

1.选择器只是补充

选择器的优先级:
每种选择器都有一个权重值,权重值越大,优先级越高,权重值一样的时候,谁后写谁的优先级就高
标签选择器:0001(1)
class选择器:0010(2)
id选择器:0100(4)
群组选择器:单独看每个选择器的权重
后代选择器:每个单独的选择器的权重和
内联样式表的优先级永远是最高的

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
        <style type="text/css">
            div #a1{
                color: yellow;
            }
            #a1{
                color: red;
            }
            .ca1{
                color: green;
            }
            a{
                color: blue;
            }
            *{
                text-decoration: none;
            }
        </style>
    </head>
    <body>
        <div id="div1">
            <div id="div2">
                <a href="" class="ca1" id="a1">哈哈哈</a>
            </div>
        </div>
    </body>
</html>
上一篇下一篇

猜你喜欢

热点阅读