css

作者: spades_K | 来源:发表于2018-04-09 16:37 被阅读14次
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>标签选择器</title>
    
    
        <style>
    
            <!--标签选择器 -->
            #header {
                background-color:black;
                color:white;
                text-align:center;
                padding:5px;
            }
            #nav {
                line-height:30px;
                background-color:#eeeeee;
                height:300px;
                width:100px;
                float:left;
                padding:5px;
            }
            #section {
                width:350px;
                float:left;
                padding:10px;
            }
            #footer {
                background-color:black;
                color:white;
                clear:both;
                text-align:center;
                padding:5px;
            }
    
            #main1{
                background: aquamarine;
            }
    
            /*类选择器 */
            .mywords{
                background: antiquewhite;
            }
    
            /*并列选择器 逻辑或的关系*/
            #header, .mywords{
                background: #ff5b8b;
            }
    
            /*复合选择器 逻辑与*/
            p.mywords{
                background: aqua;
            }
    
            /*后代选择器 包含关系 包含的所有*/
    
            div p{
                color:saddlebrown;
            }
    
            /*直接后代选择器*/
            div > p{
                color: palevioletred;
            }
            /*相邻兄弟选择器 设置的是p div下相邻的p*/
            div + p {
                color: #1d21ff;
            }
    
            /*属性选择器 可以多个属性p[name][name2] 指定选择 p[name='jack'] */
            p[name]{
                color: palevioletred;
            }
    
            /*伪类选择器 当光标闪烁的时候*/
            input:focus{
                width: 300px;
            }
            /*当鼠标点击的时候*/
            input:hover{
                background:salmon;
            }
    
    
    
        </style>
    
    </head>
    
    <body>
    
        <div id="header">
            <h1>City Gallery</h1>
        </div>
    
        <div id="nav">
            London<br>
            Paris<br>
            Tokyo<br>
        </div>
    
        <div id="section">
            <h1>London</h1>
            <p class="mywords">
                London is the capital city of England. It is the most populous city in the United Kingdom,
                with a metropolitan area of over 13 million inhabitants.
            </p>
            <p id="main1">
                Standing on the River Thames, London has been a major settlement for two millennia,
                its history going back to its founding by the Romans, who named it Londinium.
            </p>
        </div>
    
        <p name ="jack">div相邻的p标签</p>
    
        <div id="footer">
            Copyright W3School.com.cn
        </div>
    
    
        <input placeholder="我是输入框">
    
    
    
        </body>
    
    
    </html>
    
    
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>选择器优先级</title>
    
        <style>
            /*通配符 优先级最低 性能较差*/
            /*规则 相同类型就近原则和叠加原则  important(最高级)>id>类选择器>标签  id为唯一标签*/
            *{
                font-size: 23px;
            }
    
            div{
                color: salmon;
            }
    
            .jj{
                background: #80fa87;
            }
    
            .oo{
                background: #de61fa;
            }
    
        </style>
    </head>
    <body>
    
    
        <div class="jj oo">我是测试优先级的</div>
    
    </body>
    </html>
    

    相关文章

      网友评论

        本文标题:css

        本文链接:https://www.haomeiwen.com/subject/vevihftx.html