欢迎来到DIVCSS5查找CSS资料与学习DIV CSS布局技术!
CSS属性选择器
 
<meta charset="UTF-8">
<title>Title</title>
<style>
    .demo a{
        float: left;
        display: block;
        height: 50px;
        width: 50px;
        text-align: center;
        border-radius: 10px;
        background-color: aqua;
        color: blue;
        text-decoration: none;
        margin-right: 10px;
        font: bold 20px/50px Arial;
    }
    /*选中a标签里面带有id属性的元素   语法 : a[属性名或者属性名=属性值]{}
    这里面的 = 表示绝对等于
    *=  包含这个元素
    ^=  表示以什么开头
    $=  表示以什么结尾
    */
    /*a[id]{
        background-color: yellow;
    }*/
   /* a[id=first]{
        background-color: #e51010;
    }*/
    /*选中class中含有links的元素*/
    /*a[class*="links"]{
        background-color: yellow;
    }*/
    /*选中href中以http开头的元素*/
    /*a[href^=http]{
        background-color: yellow;
    }*/
    /*选中href中以pdf结尾的元素*/
    a[href$=pdf]{
        background-color: yellow;
    }
</style>
 
 
<p class="demo">
    <a href="https://www.baidu.com" class="links item first" id="first">1</a>
    <a href="https:" class="links item first" target="_blank" title="test">2</a>
    <a href="image/123.html" class="links item">3</a>
    <a href="image/123.png" class="links item">4</a>
    <a href="image/123.jpg" class="links item">5</a>
    <a href="abc" class="links item">6</a>
    <a href="abc/a.pdf" class="links item">7</a>
    <a href="/ad.pdf" class="links item">8</a>
    <a href="abd.doc" class="links item">9</a>
    <a href="djw.doc" class="links item last">10</a>
</p>

如需转载,请注明文章出处和来源网址:http://www.divcss5.com/html/h64668.shtml