Advertisement

CSS3新增选择器::before::after的经典使用场景

阅读量:

文章结构概览

        • 1.属性选择器
      • 2.结构伪类选择器

        • 2.1 :nth-child(n)(重点)
      • 3.伪元素选择器(重点)

        • 3.1伪元素的使用场景

1.属性选择器应用分析

通过元素的特定属性进行筛选,属性选择器能够实现对目标元素的定位,而无需依赖类或ID选择器。

格式一:标签名[属性名]

复制代码
    <!DOCTYPE html>
    <html lang="en">
      <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>选择器</title>
    <style>
      input[name] {
        color: blueviolet;
      }
    </style>
      </head>
      <body>
    <input type="text" name="search" />
    <input type="text" />
      </body>
    </html>
    

全部评论 (0)

还没有任何评论哟~