CSS 选择器

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        /*#i11{*/
        /*background: #FAFAD2;*/
        /*height: 100px*/
    /*}*/
    /*.c1{*/
        /*background: #FFD39B;*/
        /*height: 100px*/
    /*}*/
        /*div{*/
            /*background: black;*/
            /*color: white;*/
        /*}*/

        /*span div {*/
            /*background: #FAFAD2;*/
            /*color: brown;*/
        /*}*/
    #i1,#i2,#i3 {
        background: aliceblue;
        color: black;
    }
    /*input[type=text]{width: 100px;height: 50px }*/

    /*input[type=test]{width: 100px;height: 50px }*/

    .c1[n=test]{width: 100px;height: 150px }

    </style>


</head>
<body>
    <div id="i11">1</div>
    <div class="c1">1</div>
    <span class="c1">sasafsaf
        <div>12345</div>
    </span>

    <div id="i1">2</div>
    <div id="i2">3</div>
    <div id="i3">4</div>

    <input class="c1" type="text" n="test">
    <input class="c1" type="password">
</body>
</html>
View Code

 

 


CSS
    在标签上设置style属性
            background: #FAFAD2;
            height: 100px
    编写CSS样式:
        1.标签的style属性
        2.写在head里面,style标签中写样式
            - id选择区
                    <style>#i11{
                        background: #FAFAD2;
                        height: 100px
                    }</style>
                    
            - class选择器
                .c1{
                background: #FFD39B;
                height: 100px
                    }
                <标签 class="c1"><标签/>
            - 标签选择器:
                 div{
                 ....
                 }
                 所有div 设置上此样式
            -层级选择器
                c1.c2 div{
                ....    
                }
            - 组合选择器(逗号分隔)
                    #i1,#i2,#i3 {
                        background: aliceblue;
                        color: black;
                                }
                                    
            - 属性选择器
                对选择到的标签再通过属性再进行一次筛选

 

  3.注释
            /* 内容 */

posted @ 2020-11-27 11:27  安好_世界  阅读(99)  评论(0编辑  收藏  举报