14.伪类元素&属性选择器

伪类元素: 是指由CSS生成的标签(生成标签)

a.在首位生成标签

  .header::before {
            content: "abc";
            color: green;
            font-weight: bold;
        }

b.在末尾生成标签 

 .header::after {
            content: "ABC";
            color: red;
        }

 

选择器:: {  

                content: "";    必须要有这个content属性

            }

 <div class="header">123</div>

属性选择器

  • 选择class属性值为“i”字符开头的标签

  [class^="i"] {
            width: 60px;
            height: 60px;
            background-color: red;
            border-radius: 6px;
            margin: 5px;
        }
  • 选择class属性值以“1”字符结尾的标签,依此类推
 [class$="1"] {
            background-color: green;
        }
        [class$="2"] {
            background-color: blue;
        }
        [class$="3"] {
            background-color: purple;
        }
  • 选择class属性包含字符 “o”的标签 
 [class*="o"] {
            font-size: 50px;
        }

 

 <div class="icon1">1</div>
    <div class="icon2">2</div>
    <div class="icon3">3</div>
    <div class="icon4">4</div>
    <div class="box">5</div>

像class、 type 、src 、href 、 alt 、 id 等等这些都是标签属性

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值