6_属性选择器

2022/8/5 23:23:51

本文主要是介绍6_属性选择器,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>

    <style>
        .demo a{
            float: left;/*往左边浮动*/
            display: block;
            height: 50px;
            width: 50px;
            border-radius: 10px;/*圆角边框*/
            background: blue;/*背景颜色*/
            text-align:center;/*数字居中*/
            color: black;/*数字的颜色*/
            text-decoration: none;/*去除数字的下滑线*/
            margin-right: 5px;/*外边距:每个元素往右边偏移5px*/
            font: bold 20px/50px Arial;
        }
        /*属性名   属性名=属性值(正则)
        = 绝对等于
        *=包含这个元素
        ^=以这个开头
        $=以这个结尾
        */
        /*存在id属性的元素     a[]{}        */
       /* a[id]{
            background: red;
        }*/
        /*id=first的元素*/
        /*a[id=first]{
            background: red;
        }*/
        /*class 中有links的元素*/

        /*选中href中以http开头的元素*/
       /* a[href^=http]{
            background: chartreuse;
        }*/
        /*选中href中以pdf结尾的元素*/
        a[href$=pdf]{
            background: chartreuse;
        }


    </style>
</head>
<body>


<p class="demo">

    <a href="http://www.baidu.com"class="links item first"id="first">1</a>
    <a href="http"class="links item active" target="_blank"title="test">2</a>
    <a href="123/23.html" class="links item ">3</a>
    <a href="123/23.png" class="links item ">4</a>
    <a href="123/23.jpg" class="links item ">5</a>
    <a href="abc">6</a>
    <a href="/a.pdf">7</a>
    <a href="/as.pdf">8</a>
    <a href="a.doc">9</a>
    <a href="we.doc"class="links item last">10</a>

</p>
</body>
</html>

结果展示

 



这篇关于6_属性选择器的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程