白雪皇后 發表於 2021-6-17 15:11:00

02-CSS初级学习笔记

<p><span style="font-size: 16px"><strong>一.CSS简介</strong></span></p>
<p>  <strong>CSS说明:</strong></p>
<p>    一种描述HTML文档<span style="background-color: rgba(255, 255, 0, 1)">样式</span>的语言,具体如下: </p>
<ul>
<li>CSS&nbsp;指的是层叠样式表&nbsp;(Cascading&nbsp;Style&nbsp;Sheets)--也称级联样式表</li>
<li>CSS 描述了如何在屏幕、纸张或其他媒体上显示 HTML 元素</li>
<li>CSS&nbsp;节省了大量工作。它可以同时控制多张网页的布局</li>
<li>外部样式表存储在&nbsp;CSS 文件中</li>
</ul>
<p>  <strong>CSS作用:</strong></p>
<p>    CSS 用于定义网页的样式,包括针对不同设备和屏幕尺寸的设计和布局。</p>
<p>    HTML的操作思想是通过标签把要操作的数据包起来,再通过修改标签的属性来实现标签内数据样式的变化。</p>
<p>    但HTML 从未打算包含用于格式化网页的标签,创建 HTML 的目的是描述网页的内容,而创建CSS的目的是为了让网页能按照设计者的要求来显示。</p>
<p>  <strong>CSS和HTML的区别:</strong></p>
<p>    1.用途不同:<br>      html主要是用于文本内容,包括头部(Head)、主体(Body)两大部分,其中头部描述浏览器所需的信息,而主体则包含所要说明的具体内容。</p>
<p>      css则多用于样式,主要的用途是对网页中字体、颜色、背景、图像及其他各种元素的控制,使网页能够完全按照设计者的要求来显示。</p>
<p>    2.语法不同:</p>
<p>      HTML里代码是功能标签,如DIV、SPAN、A链接、em标签、I斜体标签、u下划线等。</p>
<p>      CSS样式代码语法:由选择器和声明块组成</p>
<p>      <img src="https://img2020.cnblogs.com/blog/1378604/202107/1378604-20210707144404807-437315212.png"></p>
<p>      选择器指向您需要设置样式的 HTML 元素,声明块包含一条或多条用分号分隔的声明。</p>
<p>  <strong>CSS注释:</strong></p>
<p>    在&nbsp;HTML 教程中,我们学习到可以使用&nbsp;<span class="code_marked">&lt;!--......--&gt;&nbsp;语法在 HTML 源代码中添加注释。</span></p>
<p><span class="code_marked">    而CSS与java一样,更常使用/*......*/的方式进行注释。</span></p>
<p>  <strong>CSS和HTML的四种结合方式(CSS使用):</strong></p>
<p>    1.直接在body中使用<span style="text-decoration: underline"><strong>自定义标签</strong></span><span style="text-decoration: underline"><strong>+style属性</strong></span>&nbsp;(因为每个html标签上面都有一个属性style。)  <span style="background-color: rgba(255, 255, 0, 1)">---行内CSS</span></p>
<p>      举例:</p>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">div </span><span style="color: rgba(255, 0, 0, 1)">style</span><span style="color: rgba(0, 0, 255, 1)">="background-color:red;color:green;"&gt;内容&lt;/div&gt;</span><span style="color: rgba(255, 0, 0, 1)">  //样式与值之间用冒号,样式与样式之间用分号</span></pre>
</div>
<p>    2.先在head中添加&lt;style type="text/css"&gt;使用了div标签的CSS代码&lt;/style&gt;,即<span style="text-decoration: underline"><strong>style标签+自定义标签</strong></span>,然后在body中直接使用div将需要设定样式的内容包起来。  <span style="background-color: rgba(255, 255, 0, 1)">---内部CSS</span></p>
<p>      举例:</p>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">style </span><span style="color: rgba(255, 0, 0, 1)">type</span><span style="color: rgba(0, 0, 255, 1)">="text/css"</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span><span style="background-color: rgba(245, 245, 245, 1); color: rgba(128, 0, 0, 1)">
   &lt;!--css代码--&gt;
   div</span><span style="background-color: rgba(245, 245, 245, 1); color: rgba(0, 0, 0, 1)">{</span><span style="background-color: rgba(245, 245, 245, 1); color: rgba(255, 0, 0, 1)">
     background-color</span><span style="background-color: rgba(245, 245, 245, 1); color: rgba(0, 0, 0, 1)">:</span><span style="background-color: rgba(245, 245, 245, 1); color: rgba(0, 0, 255, 1)">red</span><span style="background-color: rgba(245, 245, 245, 1); color: rgba(0, 0, 0, 1)">;</span><span style="background-color: rgba(245, 245, 245, 1); color: rgba(255, 0, 0, 1)">
     color</span><span style="background-color: rgba(245, 245, 245, 1); color: rgba(0, 0, 0, 1)">:</span><span style="background-color: rgba(245, 245, 245, 1); color: rgba(0, 0, 255, 1)">green</span><span style="background-color: rgba(245, 245, 245, 1); color: rgba(0, 0, 0, 1)">;</span>
   <span style="background-color: rgba(245, 245, 245, 1); color: rgba(0, 0, 0, 1)">}</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">style</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span></pre>
</div>
<p>    3.先单独写一个css文件,然后在head中添加&lt;style type="text/css"&gt;使用了import标签的CSS代码&lt;/style&gt;,即&nbsp;<span style="text-decoration: underline"><strong>style标签+@import url</strong></span>,然后在body中再使用div标签;  <span style="background-color: rgba(255, 255, 0, 1)">---外部CSS</span></p>
<p>      举例:先写一个css文件,再在head中使用import语句将css文件导入</p>
<div class="cnblogs_code">
<pre><span style="color: rgba(128, 0, 0, 1)">/*  CSS文件  */<br>div</span>{<span style="color: rgba(255, 0, 0, 1)">
    background-color</span>:<span style="color: rgba(0, 0, 255, 1)"> yellow</span>;<span style="color: rgba(255, 0, 0, 1)">
    color</span>:<span style="color: rgba(0, 0, 255, 1)"> black</span>;
}</pre>
</div>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">style </span><span style="color: rgba(255, 0, 0, 1)">type</span><span style="color: rgba(0, 0, 255, 1)">="text/css"</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span><span style="background-color: rgba(245, 245, 245, 1); color: rgba(128, 0, 0, 1)">
       @import url(div.css);
</span><span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">style</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span></pre>
</div>
<p>    4.先单独写一个css文件,再在head中添加<span style="text-decoration: underline"><strong>头标签link</strong></span>直接引入外部css文件,然后在body中再使用div标签;  <span style="background-color: rgba(255, 255, 0, 1)">---外部CSS</span></p>
<p>      举例:先写一个css文件,再使用link语句将css文件导入</p>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">link </span><span style="color: rgba(255, 0, 0, 1)">rel</span><span style="color: rgba(0, 0, 255, 1)">="stylesheet"</span><span style="color: rgba(255, 0, 0, 1)"> type</span><span style="color: rgba(0, 0, 255, 1)">="text/css"</span><span style="color: rgba(255, 0, 0, 1)"> href</span><span style="color: rgba(0, 0, 255, 1)">="div.css"</span><span style="color: rgba(0, 0, 255, 1)">/&gt;</span></pre>
</div>
<p>&nbsp;    注:第3种方式在某些老版本的浏览器中不起作用,所以我们一般使用第4种方式。</p>
<p>  样式的优先级:</p>
<p>    由上到下,由外到内,优先级是从低到高。(因为后加载的优先级肯定要更高)</p>
<p>&nbsp;</p>
<p><span style="font-size: 16px"><strong>二.CSS选择器</strong></span></p>
<p>    CSS 选择器用于“查找”(或选取)要设置样式的 HTML 元素,基本选择器主要有3种:</p>
<p>    1.元素选择器(也叫标签选择器)</p>
<p>      使用标签名作为选择器的名称,head中的标签名与body中的标签名相对应,标签名可自行定义,比如下例中的:div</p>
<div class="cnblogs_code">
<div>
<div>&lt;html&gt;</div>
<div>&nbsp;&nbsp;&nbsp;&nbsp;&lt;head&gt;</div>
<div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;title&gt;&lt;/title&gt;</div>
<div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;style&nbsp;type="text/css"&gt;</div>
<div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;div{</div>
<div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;text-align:center;</div>
<div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;background-color:&nbsp;green;</div>
<div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</div>
<div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/style&gt;</div>
<div>&nbsp;&nbsp;&nbsp;&nbsp;&lt;/head&gt;</div>
<div>&nbsp;&nbsp;&nbsp;&nbsp;&lt;body&gt;</div>
<div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;div&gt;天苍苍,野茫茫,风吹草低见牛羊&lt;/div&gt;</div>
<div>&nbsp;&nbsp;&nbsp;&nbsp;&lt;/body&gt;</div>
<div>&lt;/html&gt;</div>
</div>
</div>
<p>    2.类选择器(也叫class选择器)</p>
<p>      有特定class属性的HTML元素,如果需要选择拥有特定class的元素,请写一个<span style="background-color: rgba(255, 255, 0, 1)">句点(.)</span>字符,后面跟类名。</p>
<p>      在body中定义class的值为haha。然后在head中通过使用.haha就能设定其相差属性。</p>
<div class="cnblogs_code">
<pre><span style="color: rgba(128, 0, 0, 1)">&lt;html&gt;
    &lt;head&gt;
      &lt;title&gt;&lt;/title&gt;
      &lt;style type="text/css"&gt;
            .haha</span>{<span style="color: rgba(255, 0, 0, 1)">
                background-color</span>:<span style="color: rgba(0, 0, 255, 1)"> green</span>;
            }<span style="color: rgba(128, 0, 0, 1)">
      &lt;/style&gt;
    &lt;/head&gt;
    &lt;body&gt;
      &lt;div class="haha"&gt;变化之由表,死生之兆彰,不谋而遗迹自两同&lt;/div&gt;
      &lt;p class="haha"&gt;变化之由表&lt;/p&gt;
    &lt;/body&gt;
&lt;/html&gt;</span></pre>
</div>
<p>    3.id选择器</p>
<p>&nbsp;      每一个HTML标签上有一个属性id,且这个id在页面是唯一的,如果要选择拥有该id的元素,请写一个<span style="background-color: rgba(255, 255, 0, 1)">井号(#)</span>,后面跟id号。</p>
<p>      (注意:id名称不能以数字开头)</p>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 128, 128, 1)"> 1</span> <span style="color: rgba(128, 0, 0, 1)">&lt;html&gt;
</span><span style="color: rgba(0, 128, 128, 1)"> 2</span> <span style="color: rgba(128, 0, 0, 1)">    &lt;head&gt;
</span><span style="color: rgba(0, 128, 128, 1)"> 3</span> <span style="color: rgba(128, 0, 0, 1)">      &lt;title&gt;&lt;/title&gt;
</span><span style="color: rgba(0, 128, 128, 1)"> 4</span> <span style="color: rgba(128, 0, 0, 1)">      &lt;style type="text/css"&gt;
</span><span style="color: rgba(0, 128, 128, 1)"> 5</span> <span style="color: rgba(128, 0, 0, 1)">            #hehe</span>{
<span style="color: rgba(0, 128, 128, 1)"> 6</span> <span style="color: rgba(255, 0, 0, 1)">                background-color</span>:<span style="color: rgba(0, 0, 255, 1)"> gray</span>;
<span style="color: rgba(0, 128, 128, 1)"> 7</span>             }
<span style="color: rgba(0, 128, 128, 1)"> 8</span> <span style="color: rgba(128, 0, 0, 1)">      &lt;/style&gt;
</span><span style="color: rgba(0, 128, 128, 1)"> 9</span> <span style="color: rgba(128, 0, 0, 1)">    &lt;/head&gt;
</span><span style="color: rgba(0, 128, 128, 1)">10</span> <span style="color: rgba(128, 0, 0, 1)">    &lt;body&gt;
</span><span style="color: rgba(0, 128, 128, 1)">11</span> <span style="color: rgba(128, 0, 0, 1)">      &lt;div id="hehe"&gt;故动则有成,犹鬼神幽赞&lt;/div&gt;
</span><span style="color: rgba(0, 128, 128, 1)">12</span> <span style="color: rgba(128, 0, 0, 1)">      &lt;p id="hehe"&gt;故动则有成&lt;/p&gt;
</span><span style="color: rgba(0, 128, 128, 1)">13</span> <span style="color: rgba(128, 0, 0, 1)">    &lt;/body&gt;
</span><span style="color: rgba(0, 128, 128, 1)">14</span> <span style="color: rgba(128, 0, 0, 1)">&lt;/html&gt;</span></pre>
</div>
<p>    注意:当同时存在多种基本选择器的时候,我们就需要考虑他们的优先级,具体如下!</p>
<p>      id选择器 &gt; class选择器 &gt; 标签选择器</p>
<p>    4.扩展选择器</p>
<p>      (1).关联选择器  &lt;div&gt;&lt;p&gt;内容&lt;/p&gt;&lt;/div&gt;</p>
<p>        标签是可以嵌套的,两个或多个选择器之间产生关系时就可以选择此选择器。</p>
<p>        格式:div p{}  //div与p之间使用空格</p>
<p>      (2).组合选择器</p>
<p>        对多个不同选择器进行相同样式设置的时候应用此选择器。</p>
<p>        格式:div,p{}  //div与p之间使用逗号</p>
<p>      (3).伪元素选择器</p>
<p>        其实就是在html中预先定义好的一些选择器。(或者说当前元素处于的状态,比如:网页超链接的4种状态-点击前、鼠标悬停、点击瞬间、点击后)</p>
<p>&nbsp;</p>
<p><span style="font-size: 16px"><strong>&nbsp;三.CSS的盒子模型</strong></span></p>
<p>    在进行布局前需要把布局封装到一块一块的区域内(div)</p>
<p>    1.边框</p>
<p>      <span style="background-color: rgba(255, 255, 0, 1)">border</span>:2px solid blue  (分别代表粗细、实线、颜色)</p>
<p>      border-width:边框宽度,border-color:边框颜色,border-style:边框属性,border-radius:圆角边框</p>
<p>      border:统一设置,border-top:上边框,border-bottom:下边框,border-left:左边框,border-right:右边框</p>
<p>    2.内边距  --不允许负值</p>
<p>      距离内边框的长短,使用关键字:<span style="background-color: rgba(255, 255, 0, 1)">padding</span> (同border,可以统一设置,也可以分别设置) 单位为:px,pt,cm</p>
<p>    3.外边距  --允许负值</p>
<p>      距离外边框的长短,使用关键字:<span style="background-color: rgba(255, 255, 0, 1)">margin</span> (同border,可以统一设置,也可以分别设置)&nbsp;单位为:px,pt,cm</p>
<p>    4.背景 <span style="background-color: rgba(255, 255, 0, 1)">background</span></p>
<p>      background-color:背景颜色</p>
<p>      background-image:背景图片(默认情况下,图像会重复,以覆盖整个元素。) 也可以单独为特定元素设定背景图像。</p>
<p>      background-repeat:背景重复(设定背景图片是垂直重复还是水平重复)</p>
<p>      background-positon:背景图片的位置</p>
<p>      background-attachment:设定背景图像是滚动还是固定</p>
<p>    盒子模型(框模型)示意图如下:</p>
<p>      元素总宽度 = 宽度 + 左内边距 + 右内边距 + 左边框 + 右边框 + 左外边距 + 右外边距</p>
<p>      元素总高度 = 高度 + 上内边距 + 下内边距 + 上边框 + 下边框 + 上外边距 + 下外边距</p>
<p>    <img src="https://img2020.cnblogs.com/blog/1378604/202107/1378604-20210708121813213-1506290115.png"></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;    5.轮廓  <span style="background-color: rgba(255, 255, 0, 1)">outline</span></p>
<p>      轮廓是在元素周围绘制的一条线,在边框之外,以凸显元素。 轮廓的属性设置类似于边框。</p>
<p>      轮廓与边框的区别:轮廓是在元素边框之外绘制的,可能与其他内容重叠。而且轮廓不是元素尺寸的一部分,不影响总元素的总宽度和总高度。</p>
<p>&nbsp;</p>
<p><span style="font-size: 16px"><strong>四.CSS其它内容</strong></span></p>
<p>    1.CSS文本  <span style="background-color: rgba(255, 255, 0, 1)">text</span></p>
<p>      color:在head标签中分别设置标题和正文的文本颜色</p>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 128, 128, 1)"> 1</span>   <span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">head</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 128, 128, 1)"> 2</span>         <span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">title</span><span style="color: rgba(0, 0, 255, 1)">&gt;&lt;/</span><span style="color: rgba(128, 0, 0, 1)">title</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 128, 128, 1)"> 3</span>         <span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">style </span><span style="color: rgba(255, 0, 0, 1)">type</span><span style="color: rgba(0, 0, 255, 1)">="text/css"</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 128, 128, 1)"> 4</span> <span style="background-color: rgba(245, 245, 245, 1); color: rgba(128, 0, 0, 1)">            h1</span><span style="background-color: rgba(245, 245, 245, 1); color: rgba(0, 0, 0, 1)">{</span>
<span style="color: rgba(0, 128, 128, 1)"> 5</span> <span style="background-color: rgba(245, 245, 245, 1); color: rgba(255, 0, 0, 1)">                color</span><span style="background-color: rgba(245, 245, 245, 1); color: rgba(0, 0, 0, 1)">:</span><span style="background-color: rgba(245, 245, 245, 1); color: rgba(0, 0, 255, 1)"> green</span><span style="background-color: rgba(245, 245, 245, 1); color: rgba(0, 0, 0, 1)">;</span>
<span style="color: rgba(0, 128, 128, 1)"> 6</span>             <span style="background-color: rgba(245, 245, 245, 1); color: rgba(0, 0, 0, 1)">}</span>
<span style="color: rgba(0, 128, 128, 1)"> 7</span> <span style="background-color: rgba(245, 245, 245, 1); color: rgba(128, 0, 0, 1)">            body</span><span style="background-color: rgba(245, 245, 245, 1); color: rgba(0, 0, 0, 1)">{</span>
<span style="color: rgba(0, 128, 128, 1)"> 8</span> <span style="background-color: rgba(245, 245, 245, 1); color: rgba(255, 0, 0, 1)">                background-color</span><span style="background-color: rgba(245, 245, 245, 1); color: rgba(0, 0, 0, 1)">:</span><span style="background-color: rgba(245, 245, 245, 1); color: rgba(0, 0, 255, 1)"> lightyellow</span><span style="background-color: rgba(245, 245, 245, 1); color: rgba(0, 0, 0, 1)">;</span>
<span style="color: rgba(0, 128, 128, 1)"> 9</span> <span style="background-color: rgba(245, 245, 245, 1); color: rgba(255, 0, 0, 1)">                color</span><span style="background-color: rgba(245, 245, 245, 1); color: rgba(0, 0, 0, 1)">:</span><span style="background-color: rgba(245, 245, 245, 1); color: rgba(0, 0, 255, 1)">blue</span><span style="background-color: rgba(245, 245, 245, 1); color: rgba(0, 0, 0, 1)">;</span>
<span style="color: rgba(0, 128, 128, 1)">10</span>             <span style="background-color: rgba(245, 245, 245, 1); color: rgba(0, 0, 0, 1)">}</span>
<span style="color: rgba(0, 128, 128, 1)">11</span>         <span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">style</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 128, 128, 1)">12</span>   <span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">head</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span></pre>
</div>
<p>      text-align:文本对齐,direction:文本方向,vertical-aligh:垂直对齐方式,text-transform:转换大小写,text-indent:文字缩进</p>
<p>      letter-spacing:字母间距,line-height:行高,word-spacing:字间距</p>
<p>    2.CSS字体  <span style="background-color: rgba(255, 255, 0, 1)">font</span></p>
<p>      font-family 字体设置  五个通用字体:衬线字体(Serif),无衬线字体(Sans-serif),等宽字体(Monospace),草书字体(Cursive),幻想字体(Fantasy)</p>
<p>      font-style 字体样式设置  normal - 文字正常显示,italic - 文本以斜体显示</p>
<p>      font-weight 字体粗细  font-size 字体大小</p>
<p>    3.CSS图标</p>
<p>      向 HTML 页面添加图标的最简单方法是使用图标库,比如 Font Awesome。</p>
<p>      如需使用 Font Awesome 图标,请访问 fontawesome.com,登录并获取代码添加到 HTML 页面的 &lt;head&gt; 部分。</p>
<p>    4.CSS链接&nbsp;  <span style="background-color: rgba(255, 255, 0, 1)">link</span></p>
<p>      链接可以使用以上任何属性来设置其样式。</p>
<p>      链接的四种状态:link-未访问的链接,visited-访问过的链接,hover-鼠标悬停在链接上时,active-链接被点击的瞬间</p>
<p>        注意:hover 必须 在link 和 visited 之后,active 必须在 hover 之后。</p>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 128, 128, 1)"> 1</span> <span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">head</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 128, 128, 1)"> 2</span>   <span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">style</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 128, 128, 1)"> 3</span> <span style="background-color: rgba(245, 245, 245, 1); color: rgba(128, 0, 0, 1)">      a:link </span><span style="background-color: rgba(245, 245, 245, 1); color: rgba(0, 0, 0, 1)">{</span>
<span style="color: rgba(0, 128, 128, 1)"> 4</span> <span style="background-color: rgba(245, 245, 245, 1); color: rgba(255, 0, 0, 1)">            color</span><span style="background-color: rgba(245, 245, 245, 1); color: rgba(0, 0, 0, 1)">:</span><span style="background-color: rgba(245, 245, 245, 1); color: rgba(0, 0, 255, 1)"> red</span><span style="background-color: rgba(245, 245, 245, 1); color: rgba(0, 0, 0, 1)">;</span>
<span style="color: rgba(0, 128, 128, 1)"> 5</span>         <span style="background-color: rgba(245, 245, 245, 1); color: rgba(0, 0, 0, 1)">}</span>
<span style="color: rgba(0, 128, 128, 1)"> 6</span> <span style="background-color: rgba(245, 245, 245, 1); color: rgba(128, 0, 0, 1)">      a:visited </span><span style="background-color: rgba(245, 245, 245, 1); color: rgba(0, 0, 0, 1)">{</span>
<span style="color: rgba(0, 128, 128, 1)"> 7</span> <span style="background-color: rgba(245, 245, 245, 1); color: rgba(255, 0, 0, 1)">            color</span><span style="background-color: rgba(245, 245, 245, 1); color: rgba(0, 0, 0, 1)">:</span><span style="background-color: rgba(245, 245, 245, 1); color: rgba(0, 0, 255, 1)"> green</span><span style="background-color: rgba(245, 245, 245, 1); color: rgba(0, 0, 0, 1)">;</span>
<span style="color: rgba(0, 128, 128, 1)"> 8</span>         <span style="background-color: rgba(245, 245, 245, 1); color: rgba(0, 0, 0, 1)">}</span>
<span style="color: rgba(0, 128, 128, 1)"> 9</span> <span style="background-color: rgba(245, 245, 245, 1); color: rgba(128, 0, 0, 1)">      a:hover </span><span style="background-color: rgba(245, 245, 245, 1); color: rgba(0, 0, 0, 1)">{</span>
<span style="color: rgba(0, 128, 128, 1)">10</span> <span style="background-color: rgba(245, 245, 245, 1); color: rgba(255, 0, 0, 1)">            color</span><span style="background-color: rgba(245, 245, 245, 1); color: rgba(0, 0, 0, 1)">:</span><span style="background-color: rgba(245, 245, 245, 1); color: rgba(0, 0, 255, 1)"> hotpink</span><span style="background-color: rgba(245, 245, 245, 1); color: rgba(0, 0, 0, 1)">;</span>
<span style="color: rgba(0, 128, 128, 1)">11</span>         <span style="background-color: rgba(245, 245, 245, 1); color: rgba(0, 0, 0, 1)">}</span>
<span style="color: rgba(0, 128, 128, 1)">12</span> <span style="background-color: rgba(245, 245, 245, 1); color: rgba(128, 0, 0, 1)">      a:active </span><span style="background-color: rgba(245, 245, 245, 1); color: rgba(0, 0, 0, 1)">{</span>
<span style="color: rgba(0, 128, 128, 1)">13</span> <span style="background-color: rgba(245, 245, 245, 1); color: rgba(255, 0, 0, 1)">            color</span><span style="background-color: rgba(245, 245, 245, 1); color: rgba(0, 0, 0, 1)">:</span><span style="background-color: rgba(245, 245, 245, 1); color: rgba(0, 0, 255, 1)"> blue</span><span style="background-color: rgba(245, 245, 245, 1); color: rgba(0, 0, 0, 1)">;</span>
<span style="color: rgba(0, 128, 128, 1)">14</span>         <span style="background-color: rgba(245, 245, 245, 1); color: rgba(0, 0, 0, 1)">}</span>
<span style="color: rgba(0, 128, 128, 1)">15</span>   <span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">style</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 128, 128, 1)">16</span> <span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">head</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span></pre>
</div>
<p>    5.CSS列表  <span style="background-color: rgba(255, 255, 0, 1)">list</span></p>
<p>      list-style-type :无序(ul)和有序(ol),list-style-image :将图像指定为列表项标记,list-style-position:列表项标记的位置(设定项目符号在列表项内还是外)</p>
<p>    6.CSS表格  <span style="background-color: rgba(255, 255, 0, 1)">table</span></p>
<p>      使用border设置表格边框</p>
<p>  </p>

</div>
<div id="MySignature" role="contentinfo">
    昨夜雨疏风骤,浓睡不消残酒。试问卷帘人,却道海棠依旧。知否知否,应是绿肥红瘦!<br><br>
来源:https://www.cnblogs.com/benon94/p/14893551.html
頁: [1]
查看完整版本: 02-CSS初级学习笔记