wloe2gf 发表于 2024-6-30 04:57:53

前端知识(二)CSS选取器(很要紧)


    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">各位大哥养成好习惯,点赞再看,关注不迷路,前后端知识<span style="color: black;">这儿</span>都有,由浅入深,<span style="color: black;">咱们</span><span style="color: black;">一块</span>进步,你的支持<span style="color: black;">便是</span>我最大的动力。</p>第01<span style="color: black;">周期</span>.前端<span style="color: black;">基本</span>.CSS<span style="color: black;">基本</span><span style="color: black;">选取</span>器<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">CSS<span style="color: black;">选取</span>器(重点)</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">学习<span style="color: black;">目的</span>:</p>理解能说出<span style="color: black;">选取</span>器的<span style="color: black;">功效</span>id<span style="color: black;">选取</span>器和类<span style="color: black;">选取</span>器的区别应用能够<span style="color: black;">运用</span><span style="color: black;">基本</span><span style="color: black;">选取</span>器给页面元素添加样式<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">1. CSS<span style="color: black;">选取</span>器<span style="color: black;">功效</span>(重点)</p>
    <div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://pic2.zhimg.com/80/v2-812015ac758429c8b83472a529e99d5d_720w.webp" style="width: 50%; margin-bottom: 20px;"></div>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">如上图<span style="color: black;">因此</span>,要把里面的小黄人分为2组,最快的<span style="color: black;">办法</span>怎办?</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">非常多</span>, <span style="color: black;">例如</span> 一只眼睛的一组,剩下的一组</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">选取</span>器的<span style="color: black;">功效</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">​ 找到特定的HTML页面元素</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">一句话说出<span style="color: black;">她们</span>:</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">CSS<span style="color: black;">选取</span>器干啥的? <span style="color: black;">选取</span>标签用的, 把<span style="color: black;">咱们</span>想要的标签<span style="color: black;">选取</span>出来 </p><span style="color: black;">必要</span>记住的<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">css <span style="color: black;">便是</span> 分两件事, 选对人, 做对事。</p>
    <div style="color: black; text-align: left; margin-bottom: 10px;">h3 { color: red; }</div>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">这段代码<span style="color: black;">便是</span>2件事, 把 h3选出来, <span style="color: black;">而后</span> 把它变<span style="color: black;">成为了</span> 红色。 以后<span style="color: black;">咱们</span>都这么干。</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">选取</span>器分为<span style="color: black;">基本</span><span style="color: black;">选取</span>器和 复合<span style="color: black;">选取</span>器,<span style="color: black;">咱们</span><span style="color: black;">这儿</span>先讲解一下 <span style="color: black;">基本</span><span style="color: black;">选取</span>器。</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">2. CSS<span style="color: black;">基本</span><span style="color: black;">选取</span>器</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">2.1 标签<span style="color: black;">选取</span>器</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">概念:</p>标签<span style="color: black;">选取</span>器(元素<span style="color: black;">选取</span>器)<span style="color: black;">指的是</span>用HTML标签名<span style="color: black;">叫作</span><span style="color: black;">做为</span><span style="color: black;">选取</span>器,按标签名<span style="color: black;">叫作</span><span style="color: black;">归类</span>,为页面中某一类标签指定统一的CSS样式。语法:<div style="color: black; text-align: left; margin-bottom: 10px;">标签名{属性1:属性值1; 属性2:属性值2; 属性3:属性值3; }</div>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">功效</span>:</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">标签<span style="color: black;">选取</span>器 <span style="color: black;">能够</span>把某一类标签<span style="color: black;">所有</span><span style="color: black;">选取</span>出来 <span style="color: black;">例如</span>所有的div标签 和 所有的 span标签优点:</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">是能快速为页面中同类型的标签统<span style="color: black;">同样</span>式缺点:</p><span style="color: black;">不可</span>设计差异化样式。总结 口诀:<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">标签<span style="color: black;">选取</span>器,</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">页面同选起。</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">直接写标签,</p><span style="color: black;">所有</span>不放弃。思考: <span style="color: black;">倘若</span>想要差异化<span style="color: black;">选取</span><span style="color: black;">区别</span>的标签,怎么办呢? <span style="color: black;">便是</span>说 我想单独选一个<span style="color: black;">或</span>某几个标签呢?<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">2.2 类<span style="color: black;">选取</span>器</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">类<span style="color: black;">选取</span>器<span style="color: black;">运用</span>“.”(英文点号)进行标识,后面紧跟类名.</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">语法:</p>类名<span style="color: black;">选取</span>器<div style="color: black; text-align: left; margin-bottom: 10px;">.类名 { 属性1:属性值1; 属性2:属性值2; 属性3:属性值3; }
    </div>标签<div style="color: black; text-align: left; margin-bottom: 10px;">&lt;p class=类名&gt;&lt;/p&gt;</div>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">优点:</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">能够</span>为元素对象定义单独或相同的样式。 <span style="color: black;">能够</span><span style="color: black;">选取</span>一个<span style="color: black;">或</span>多个标签<span style="color: black;">重视</span></p>类<span style="color: black;">选取</span>器<span style="color: black;">运用</span>“.”(英文点号)进行标识,后面紧跟类名(自定义,<span style="color: black;">咱们</span>自己命名的)长名<span style="color: black;">叫作</span>或词组<span style="color: black;">能够</span><span style="color: black;">运用</span>中横线来为<span style="color: black;">选取</span>器命名。不要纯数字、中文等命名, <span style="color: black;">尽可能</span><span style="color: black;">运用</span>英文字母来<span style="color: black;">暗示</span>。<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">命名规范: 见附件(Web前端<span style="color: black;">研发</span>规范手册.doc)</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">命名是我们通俗约定的,<span style="color: black;">然则</span><span style="color: black;">无</span>规定<span style="color: black;">必要</span>用这些常用的命名。</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">记忆口诀</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">差异化<span style="color: black;">选取</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">一个或多个</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">上面点定义</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">类名别写错</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">谁用谁调用</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">class来做。</p>嘿嘿,工作类最多。<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">案例:</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">用Css实现谷歌的logo</p>

    <div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://pic4.zhimg.com/80/v2-cfb8ef9e7778e78f592c1097469893ab_720w.webp" style="width: 50%; margin-bottom: 20px;"></div>
    <div style="color: black; text-align: left; margin-bottom: 10px;"><span style="color: black;">&lt;</span><span style="color: black;">head</span><span style="color: black;">&gt;</span>
      <span style="color: black;">&lt;</span><span style="color: black;">meta</span> <span style="color: black;">charset</span><span style="color: black;">=</span><span style="color: black;">"utf-8"</span><span style="color: black;">&gt;</span>
      <span style="color: black;">&lt;</span><span style="color: black;">style</span><span style="color: black;">&gt;</span>

      <span style="color: black;">.</span><span style="color: black;">blue</span> <span style="color: black;">{</span>
      <span style="color: black;">color</span><span style="color: black;">:</span> <span style="color: black;">blue</span><span style="color: black;">;</span>
      <span style="color: black;">font-size</span><span style="color: black;">:</span> <span style="color: black;">100</span><span style="color: black;">px</span><span style="color: black;">;</span>
      <span style="color: black;">}</span>
      <span style="color: black;">.</span><span style="color: black;">red</span> <span style="color: black;">{</span>
      <span style="color: black;">color</span><span style="color: black;">:</span> <span style="color: black;">red</span><span style="color: black;">;</span>
      <span style="color: black;">font-size</span><span style="color: black;">:</span> <span style="color: black;">100</span><span style="color: black;">px</span><span style="color: black;">;</span>
      <span style="color: black;">}</span>
      <span style="color: black;">.</span><span style="color: black;">orange</span> <span style="color: black;">{</span>
      <span style="color: black;">color</span><span style="color: black;">:</span> <span style="color: black;">orange</span><span style="color: black;">;</span>
      <span style="color: black;">font-size</span><span style="color: black;">:</span> <span style="color: black;">100</span><span style="color: black;">px</span><span style="color: black;">;</span>
      <span style="color: black;">}</span>
      <span style="color: black;">.</span><span style="color: black;">green</span> <span style="color: black;">{</span>
      <span style="color: black;">color</span><span style="color: black;">:</span> <span style="color: black;">green</span><span style="color: black;">;</span>
      <span style="color: black;">font-</span>
    </div>




飘雨的姑娘 发表于 2024-8-31 16:19:02

“NB”(牛×的缩写,表示叹为观止)‌

dhfgh 发表于 2024-9-10 11:23:44

楼主节操掉了,还不快捡起来!

b1gc8v 发表于 2024-10-20 12:20:28

哈哈、笑死我了、太搞笑了吧等。

nykek5i 发表于 2024-10-26 12:50:09

交流如星光璀璨,点亮思想夜空。

wrjc1hod 发表于 6 天前

软文发布平台 http://www.fok120.com/
页: [1]
查看完整版本: 前端知识(二)CSS选取器(很重要)