CSS 选择器

什么是选择器? 就是你选择给谁,加特技。

在head标签中,我们有style标签,我们知道,这个style就是让我们给 body里面的 标签加特技的,而我们现在挑选一些标签进行加特技,这就成为了 css选择器

我们可以通过很多指名道姓的方法,声明某些标签需要处理。class了,id了,直接说出某个标签名字了等等.

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>选择器</title>
    <style type="text/css">
       .cla1{      /* 用点,找到名叫 cla1的类*/
           font-size:90px;
           color: #25f631;
       }
       .cla2{      /*用点,找到名叫cla2的类*/
           font-size: 60px;
           color: #12d;
       }
       #张三{  /*用# 找到 id = 张三 的标签,注意!!我们非常不推荐id 重复!*/
           font-size:888px;
           color: #ff335f;
       }
       #李四{ /*用# 找到 id = 李四 的标签*/
           font-size: 666px;
           color: #41daeb;
       }
       [href="css基础.html"]{    /*想让哪个链接加特技,直接指明*/
           font-size: 2px;
           color: antiquewhit;
       }
        a{                         /*此处这个a想去控制所有a标签,可是不可能,人家优先级高*/
            font-size: 123px;
            color: #b075e3;
        }
        p{             /*直接指出是 所有的 p 标签 */
            color: #e4816b;
        }
    </style>

</head>
<body>
     <a class="cla1"> css!</a>          <br>
     <a class="cla1"> css!</a>          <br>
     <a class="cla2"> css!</a>          <br>
     <p>cssssss!!!</p>
     <a id="张三"> css!</a>              <br>
     <a id="张三"> css!</a>              <br>
     <a id="李四"> css!</a>              <br>
     <a href="css基础.html"> css!</a>   <br>
     <a href="css选择器.html"> css!</a> <br>

</body>
</html>

试一试!👇

http://www.w3school.com.cn/tiy/t.asp?f=html_a

 

posted @ 2018-08-12 18:34  3532  阅读(131)  评论(0编辑  收藏  举报