整合營銷服務商

          電腦端+手機端+微信端=數據同步管理

          免費咨詢熱線:

          CSS是什么?這一篇全解,絕對有你想要的

          CSS 是什么?

          CSS是Cascading Style Sheets的簡稱,中文稱為層疊樣式表。

          屬性和屬性值用冒號隔開,以分號結尾。

          CSS 四種引入方式:

          1.行內式

          行內式是在標簽的style屬性中設定CSS樣式。

          <div style="..."></div>

          2.嵌入式

          嵌入式是將CSS樣式集中寫在網頁的<head>標簽的<style></style>標簽對中。

          <head>
          
              ...
          
              <style type="text/css">
          
                  ...此處寫CSS樣式
          
              </style>
          
          </head>

          3.導入式
          將一個獨立的.css文件引入HTML文件中,導入式使用@import 引入外部CSS文件,<style>標記也是寫在<head>標記中。

          導入式會在整個網頁裝載完后再裝載CSS文件。

          <head>
          
              ...
          
              <style type="text/css">
          
                  @import "My.css"; 此處注意.css文件的路徑
          
              </style>
          
          </head>

          4.鏈接式
          將一個獨立的.css文件引入到HTML文件中,使用<link>標記寫在<head>標記中。

          鏈接式會以網頁文件主體裝載前裝載CSS文件。

          <head>
          
              ...
          
              <link href="My.css" rel="stylesheet" type="text/css">
          
          </head>
          
          

          樣式應用順序:

          • 行內樣式優先級最高
          • 針對相同的樣式屬性,不同的樣式屬性將以合并的方式呈現
          • 相同樣式并且相同屬性,呈現方式在<head>中的順序決定,后面會覆蓋前面屬性
          • !important 指定樣式規則應用最優先
          .nick {
              color: yellow !important;
          }

          選擇器(Selector)

          基本選擇器:

          1.通用元素選擇器

          * 表示應用到所有的標簽。

          * {color: yellow}

          2.標簽選擇器

          匹配所有使用 div 標簽的元素(可以匹配所有標簽)

          div {color: yellow}

          3.類選擇器

          匹配所有class屬性中包含info的元素。

          語法:.類名{樣式}(類名不能以數字開頭,類名要區分大小寫。)

          .Mycolor {color: yellow}
          <h3 class="Mycolor">nick</h3>

          4.ID選擇器

          使用id屬性來調用樣式,在一個網頁中id的值都是唯一的(是W3C規范而不是規則,所以不會報錯)。

          語法:#ID名{樣式}(ID名不能以數字開頭)

          #Mycolor {color: yellow}
          <h3 id="Mycolor">Nick.</h3>

          組合選擇器:

          1.多元素選擇器

          同時匹配h3,h4標簽,之間用逗號分隔。

          h3,h4 {color: yellow;}
          <h3>Nick</h3>
          <h4>Jenny</h4>
          

          2.后代元素選擇器

          匹配所有div標簽里嵌套的P標簽,之間用空格分隔。

              div p {color: yellow;}
          <div>
              <p>Nick</p>
              <div>
                  <p>Nick</p>
              </div>
          </div>

          3.子元素選擇器

          匹配所有div標簽里嵌套的子P標簽,之間用>分隔。

              div > p {color: yellow;}
          <div>
              <p>Nick</p>
              <p>Nick</p>
          </div>

          4.毗鄰元素選擇器

          匹配所有緊隨div標簽之后的同級標簽P,之間用+分隔(只能匹配一個)。

              div + p {color: yellow;}
          <div>Nick</div>
          <p>Nick</p>

          屬性選擇器:

          1.[title] & P[title]

          設置所有具有title屬性的標簽元素;

          設置所有具有title屬性的P標簽元素。

              [title]
              {
                  color: yellow;
              }
              p[title]
              {
                  color: yellow;
              }
           
          <div title>Nick</div>
          <p title>Nick</p>

          2.[title=Nick]

          設置所有title屬性等于“Nick”的標簽元素。

              [title="Nick"]
              {
                  color: yellow;
              }
          <p title="Nick">Nick</p>

          3.[title~=Nick]

          設置所有title屬性具有多個空格分隔的值、其中一個值等于“Nick”的標簽元素。

              [title~="Nick"]
              {
                  color: yellow;
              }
          <p title="Nick Jenny">Nick</p>
          <p title="Jenny Nick">Nick</p>

          4.[title|=Nick]

          設置所有title屬性具有多個連字號分隔(hyphen-separated)的值、其中一個值以"Nick"開頭的標簽元素。

          例:lang屬性:"en"、"en-us"、"en-gb"等等

              [title|="Nick"]
              {
                  color: yellow;
              }
           <p title="Nick-Jenny">Nick</p>
          

          5.[title^=Nick]

          設置屬性值以指定值開頭的每個標簽元素。

              [title^="Nick"]
              {
                  color: yellow;
              }
          <p title="NickJenny">Nick</p>

          6.[title$=Nick]

          設置屬性值以指定值結尾的每個標簽元素。

              [title$="Nick"]
              {
                  color: yellow;
              }
          <p title="JennyNick">Nick</p>

          7.[title*=Nick]

          設置屬性值中包含指定值的每個元素

          [title*="Nick"]
              {
                  color: yellow;
              }
           
          <p title="SNickJenny">Nick</p>

          偽類選擇器:

          1. link、hover、active、visited

          • a:link(未訪問的鏈接狀態),用于定義了常規的鏈接狀態。
          • a:hover(鼠標放在鏈接上的狀態),用于產生視覺效果。
          • a:active(在鏈接上按下鼠標時的狀態)。
          • a:visited(已訪問過的鏈接狀態),可以看出已經訪問過的鏈接。
              a:link{color: black}
              a:hover{color: yellow}
              a:active{color: blue}
              a:visited{color: red} 
          <a href="#">Nick</a>

          2. before、after

          • P:before 在每個<p>元素的內容之前插入內容;
          • P:after 在每個<p>元素的內容之后插入內容。
              p {
                  color: yellow;
              }
              p:before{
                  content: "before...";
              }
              p:after{
                  content: "after...";
              }
           <p> Nick </p>  

          常用屬性

          1. 顏色屬性:

          color

          • HEX(十六進制色:color: #FFFF00 --> 縮寫:#FF0)
          • RGB(紅綠藍,使用方式:color:rgb(255,255,0)或者color:rgb(100%,100%,0%))
          • RGBA(紅綠藍透明度,A是透明度在0~1之間取值。使用方式:color:rgba(255,255,0,0.5))
          • HSL(CSS3有效,H表示色調,S表示飽和度,L表示亮度,使用方式:color:hsl(360,100%,50%))
          • HSLA(和HSL相似,A表示Alpha透明度,取值0~1之間。)

          transparent

          • 全透明,使用方式:color: transparent;

          opacity

          • 元素的透明度,語法:opacity: 0.5;
          • 屬性值在0.0到1.0范圍內,0表示透明,1表示不透明。
          • filter濾鏡屬性(只適用于早期的IE瀏覽器,語法:filter:alpha(opacity:20);)。

          2. 字體屬性:

          font-style: 用于規定斜體文本

          • normal 文本正常顯示
          • italic 文本斜體顯示
          • oblique 文本傾斜顯示

          font-weight: 設置文本的粗細

          • normal(默認)
          • bold(加粗)
          • bolder(相當于<strong>和<b>標簽)
          • lighter (常規)
          • 100 ~ 900 整百(400=normal,700=bold)

          font-size: 設置字體的大小

          • 默認值:medium
          • <absolute-size>可選參數值:xx-small、 x-small、 small、 medium、 large、 x-large、 xx-large
          • <relative-size>相對于父標簽中字體的尺寸進行調節。可選參數值:smaller、 larger
          • <percentage>百分比指定文字大小。
          • <length>用長度值指定文字大小,不允許負值。

          font-family:字體名稱

          • 使用逗號隔開多種字體(優先級從前向后,如果系統中沒有找到當前字體,則往后面尋找)

          font:簡寫屬性

          • 語法:font:字體大小/行高 字體;(字體要在最后)

          3. 文本屬性:

          white-space: 設置元素中空白的處理方式

          • normal:默認處理方式。
          • pre:保留空格,當文字超出邊界時不換行
          • nowrap:不保留空格,強制在同一行內顯示所有文本,直到文本結束或者碰到br標簽
          • pre-wrap:保留空格,當文字碰到邊界時換行
          • pre-line:不保留空格,保留文字的換行,當文字碰到邊界時換行

          direction: 規定文本的方向

          • ltr 默認,文本方向從左到右。
          • rtl 文本方向從右到左。

          text-align: 文本的水平對齊方式

          • left
          • center
          • right

          line-height: 文本行高

          • normal 默認

          vertical-align: 文本所在行高的垂直對齊方式

          • baseline 默認
          • sub 垂直對齊文本的下標,和<sub>標簽一樣的效果
          • super 垂直對齊文本的上標,和<sup>標簽一樣的效果
          • top 對象的頂端與所在容器的頂端對齊
          • text-top 對象的頂端與所在行文字頂端對齊
          • middle 元素對象基于基線垂直對齊
          • bottom 對象的底端與所在行的文字底部對齊
          • text-bottom 對象的底端與所在行文字的底端對齊

          text-indent: 文本縮進

          letter-spacing: 添加字母之間的空白

          word-spacing: 添加每個單詞之間的空白

          text-transform: 屬性控制文本的大小寫

          • capitalize 文本中的每個單詞以大寫字母開頭。
          • uppercase 定義僅有大寫字母。
          • lowercase 定義僅有小寫字母。

          text-overflow: 文本溢出樣式

          • clip 修剪文本。
          • ellipsis 顯示省略符號...來代表被修剪的文本。
          • string 使用給定的字符串來代表被修剪的文本。
          <!DOCTYPE html>
          <html lang="en">
          <head>
              <meta charset="UTF-8">
              <title>Title</title>
              <!--<link href="cc2.css" rel="stylesheet" type="text/css">-->
              <style>
                  div {
                      width: 100px;
                      height: 100px;
                      white-space: nowrap;
                      overflow: hidden;
                      text-overflow: ellipsis;
                  }
              </style>
          </head>
          <body>
              <div>索寧 索寧 索寧 索寧 索寧 索寧 索寧 索寧 索寧 索寧 索寧 索寧 索寧 索寧 索寧 索寧 索寧 索寧 索寧 索寧</div>
          </body>
          </html>

          text-decoration: 文本的裝飾

          • none 默認。
          • underline 下劃線。
          • overline 上劃線。
          • line-through 中線。

          text-shadow:文本陰影

          • 第一個參數是左右位置
          • 第二個參數是上下位置
          • 第三個參數是虛化效果
          • 第四個參數是顏色
          • text-shadow: 5px 5px 5px #888;

          word-wrap:自動換行

          • word-wrap: break-word;
          <!DOCTYPE html>
          <html lang="en">
          <head>
              <meta charset="UTF-8">
              <title>Title</title>
              <style>
                  p {
                      width: 150px;
                      height: 160px;
                      background-color: #FFA500;
                      /*邊框陰影*/
                      box-shadow: 10px 10px 5px #888;
                      /*自動換行*/
                      word-wrap: break-word;
                  }
                  h1 {
                      text-shadow: 5px 5px 5px #888;
                  }
              </style>
          </head>
          <body>
              <p>
                  When you are old and grey and full of sleep,And nodding by the fire, take down this book,And slowly read, and dream of the soft look
              </p>
              <h1>索寧</h1>
          </body>
          </html>    

          a {
              text-decoration: none;
              /*去除a標簽下劃線*/
          }

          4. 背景屬性

          background-color: 背景顏色

          background-image 設置圖像為背景

          • url("http://images.cnblogs.com/cnblogs_com/suoning/845162/o_ns.png"); 圖片地址
          • background-image:linear-gradient(green,blue,yellow,red,black); 顏色漸變效果

          background-position 設置背景圖像的位置坐標

          • background-position: center center; 圖片置中,x軸center,y軸center
          • 1px -195px 截取圖片某部分,分別代表坐標x,y軸

          background-repeat 設置背景圖像不重復平鋪

          • no-repeat 設置圖像不重復,常用
          • round 自動縮放直到適應并填充滿整個容器
          • space 以相同的間距平鋪且填充滿整個容器

          background-attachment 背景圖像是否固定或者隨著頁面的其余部分滾動

          background 簡寫

          • background: url("o_ns.png") no-repeat 0 -196px;
          • background: url("o_ns.png") no-repeat center bottom 15px;
          • background: url("o_ns.png") no-repeat left 30px bottom 15px;

          5. 列表屬性

          list-style-type: 列表項標志的類型

          • none 去除標志
          • decimal-leading-zero; 02.
          • square; 方框
          • circle; 空心圓
          • upper-alph; & disc; 實心圓

          list-style-image:將圖象設置為列表項標志

          list-style-position:列表項標志的位置

          • inside
          • outside

          list-style:縮寫

          頁面布局

          1. 邊框

          border-style:邊框樣式

          • solid 默認,實線
          • double 雙線
          • dotted 點狀線條
          • dashed 虛線

          border-color:邊框顏色

          border-width:邊框寬度

          border-radius:圓角

          • 1個參數:四個角度應用
          • 2個參數:第一個參數應用于 左上、右下;第二個參數應用于 左下、右上
          • 3個參數:第一個參數應用于 左上;第二個參數應用于 左下、右上;第三個參數應用于右下
          • 4個參數:左上、右上、右下、左下(順時針)

          border: 簡寫

          • border: 2px yellow solid;

          box-shadow:邊框陰影

          • 第一個參數是左右位置
          • 第二個參數是上下位置
          • 第三個參數是虛化效果
          • 第四個參數是顏色
          • box-shadow: 10px 10px 5px #888;
          <!DOCTYPE html>
          <html lang="en">
          <head>
              <meta charset="UTF-8">
              <title>Title</title>
              <style>
                  div {
                      border:2px solid;
                      border-radius:25px;
                      width: 140px;
                  }
              </style>
          </head>
          <body>
              <div>
                   點贊哦!dear. 
              </div>
          </body>
          </html>

          <!DOCTYPE html>
          <html lang="en">
          <head>
              <meta charset="UTF-8">
              <title>Title</title>
              <style>
                  .radius1 {
                      display: inline-block;
                      width: 100px;
                      height: 100px;
                      background-color: yellow;
                      border-radius: 20px;
                  }
                  .radius2 {
                      display: inline-block;
                      width: 100px;
                      height: 100px;
                      background-color: red;
                      border-radius: 20px 35px;
                  }
                  .radius3 {
                      display: inline-block;
                      width: 100px;
                      height: 100px;
                      background-color: blue;
                      border-radius: 20px 35px 50px;
                  }
                  .radius4 {
                      display: inline-block;
                      width: 100px;
                      height: 100px;
                      background-color: green;
                      border-radius: 20px 35px 50px 60px;
                  }
              </style>
          </head>
          <body>
              <div>
                  <span class="radius1"></span>
                  <span class="radius2"></span>
                  <span class="radius3"></span>
                  <span class="radius4"></span>
              </div>
          </body>
          </html>

          邊框實現各種三角符號:

          <!DOCTYPE html>
          <html lang="en">
          <head>
              <meta charset="UTF-8">
              <title>Title</title>
              <style>
                  .triangle-one {
                      display: inline-block;
                      border-top: 50px red solid;
                      border-right: 50px green solid;
                      border-bottom: 50px yellow solid;
                      border-left: 50px blue solid;
                  }
                  .triangle-two {
                      display: inline-block;
                      border-top: 0 red solid;
                      border-right: 50px green solid;
                      border-bottom: 50px yellow solid;
                      border-left: 50px blue solid;
                  }
                  .triangle-stree {
                      display: inline-block;
                      border-top: 50px red solid;
                      border-right: 0 green solid;
                      border-bottom: 50px yellow solid;
                      border-left: 50px blue solid;
                  }
                  .triangle-four {
                      display: inline-block;
                      border-top: 50px red solid;
                      border-right: 0 green solid;
                      border-bottom: 0 yellow solid;
                      border-left: 50px blue solid;
                  }
           
                  .triangle-five {
                      display: inline-block;
                      border: 50px transparent solid;
                      border-top: 50px red solid;
                  }
                  .triangle-six {
                      display: inline-block;
                      border: 50px transparent solid;
                      border-bottom: 50px yellow solid;
                  }
                  .triangle-seven {
                      display: inline-block;
                      border: 50px transparent solid;
                      border-top: 60px red solid;
                      border-right: 0;
                  }
                  .triangle-eight {
                      display: inline-block;
                      border: 50px transparent solid;
                      border-left: 30px yellow solid;
                      border-bottom: 0;
                  }
              </style>
          </head>
          <body>
              <div class="triangle-one"></div>
              <div class="triangle-two"></div>
              <div class="triangle-stree"></div>
              <div class="triangle-four"></div>
              <div class="triangle-five"></div>
              <div class="triangle-six"></div>
              <div class="triangle-seven"></div>
              <div class="triangle-eight"></div>
          </body>
          </html>

          <!DOCTYPE html>
          <html lang="en">
          <head>
              <meta charset="UTF-8">
              <title>Title</title>
              <style>
                  .back {
                      width: 1000px;
                      height: 1000px;
                      margin: 0 auto;
                      background-color: #ddd;
                      position: relative;
                  }
                  .back-in {
                      position: absolute;
                      width: 1020px;
                      height: 45px;
                      left: -20px;
                      top: 50px;
                      background-color: #2F4F4F;
                  }
                  .back-img {
                      border: 20px solid transparent;
                      border-top: 10px solid dimgrey;
                      border-right: 0;
                      display: inline-block;
                      position: absolute;
                      top: 95px;
                      left: -20px;
                  }
                  .back-font {
                      line-height: 9px;
                      margin-left: 30px;
                      color: white;
                  }
              </style>
          </head>
          <body>
              <div class="back">
                  <div class="back-in"><h3 class="back-font">妹子求關注 ^.^</h3></div>
                  <div class="back-img"></div>
              </div>
          </body>
          </html>

          2.★ 盒子模型

          一個標準的盒子模型:

          padding:用于控制內容與邊框之間的距離;

          margin: 用于控制元素與元素之間的距離;

          一個參數,應用于四邊。

            兩個參數,第一個用于上、下,第二個用于左、右。

            三個參數,第一個用于上,第二個用于左、右,第三個用于下。

          邊框在默認情況下會定位于瀏覽器窗口的左上角,但是并沒有緊貼著瀏覽器的窗口的邊框,這是因為body本身也是一個盒子,外層還有html,
          在默認情況下,body距離html會有若干像素的margin,所以body中的盒子不會緊貼瀏覽器窗口的邊框了。
          
          解決方法:
          body {
              margin: 0;
          }

          3.★ display

          • none 不顯示。
          • block 顯示為塊級元素。
          • inline 顯示為內聯元素。
          • inline-block 行內塊元素(會保持塊元素的高寬)。
          • list-item 顯示為列表元素。

          4. visibility

          • visible 元素可見
          • hidden 元素不可見
          • collapse 當在表格元素中使用時,此值可刪除一行或一列,不會影響表格的布局。

          5.★ float 浮動

          讓一行顯示兩個塊級標簽,會脫離文檔流

          • none
          • left 左浮動
          • right 右浮動

          clear 清除浮動:

          • none : 默認值。允許兩邊都可以有浮動對象
          • left : 不允許左邊有浮動對象
          • right : 不允許右邊有浮動對象
          • both : 不允許兩邊有浮動對象

          6. clip 剪裁圖像

          rect 剪裁定位元素:

          • auto 默認值,無剪切
          • 上-右-下-左(順時針)的順序提供四個偏移值
          • 區域外的部分是透明的
          • 必須指定 position:absolute;
          • 例:clip:rect(0px,60px,200px,0px);

          7. overflow 設置當對象的內容超過其指定高度及寬度時如何顯示內容

          • visible 默認值,內容不會被修剪,會呈現在元素框之外。
          • hidden 內容會被修剪,并且其余內容是不可見的。
          • scroll 內容會被修剪,但是瀏覽器會顯示滾動條以便查看其余的內容。
          • auto 如果內容被修剪,則瀏覽器會顯示滾動條以便查看其余的內容。

          8.★ position 規定元素的定位類型

          • 通過以下四種屬性進行定位:
          • left
          • top
          • right
          • bottom
          • z-index

          9. z-index 元素層疊順序

          • z-index 僅在定位元素上有效(例:position:absolute;)
          • 可以指定負數屬性值(例:-1;)
          <!DOCTYPE html>
          <html lang="en">
          <head>
              <meta charset="UTF-8">
              <title>Title</title>
              <style>
                  .z-index1 {
                      width: 100px;
                      height: 100px;
                      background-color: yellow;
                      position: absolute;
                      z-index: -1;
                  }
                  .z-index2 {
                      width: 100px;
                      height: 100px;
                      background-color: red;
                      position: absolute;
                      top: 20px;
                      left: 20px;
                      z-index: 5;
                  }
              </style>
          </head>
          <body>
              <div class="z-index1"></div>
              <div class="z-index2"></div>
          </body>
          </html>

          10. outline 邊框輪廓

          • outline-width 輪廓寬度
          • outline-color 輪廓顏色
          • outline-style 輪廓樣式

          11. zoom 縮放比例

          <!DOCTYPE html>
          <html lang="en">
          <head>
              <meta charset="UTF-8">
              <title>Title</title>
              <style>
                  .zoom1 {
                      zoom: 100%;
                  }
                  .zoom2 {
                      zoom: 150%;
                  }
                  .zoom3 {
                      zoom: 200%;
                  }
              </style>
          </head>
          <body>
              <div class="zoom1">Nick 100%</div>
              <div class="zoom2">Nick 200%</div>
              <div class="zoom3">Nick 300%</div>
          </body>
          </html>

          12. cursor 鼠標的類型形狀

          鼠標放在以下單詞上,There will be a miracle:

          url: 自定義光標

          <!DOCTYPE html>
          <html lang="en">
          <head>
              <meta charset="UTF-8">
              <title>Title</title>
              <!--<link href="cc2.css" rel="stylesheet" type="text/css">-->
              <style>
                  body {
                      cursor: url("mouse.png"), auto;
                      /*圖片地址:http://images.cnblogs.com/cnblogs_com/suoning/845162/o_mouse.png*/
                  }
              </style>
          </head>
          <body>
              <div><img src="http://images.cnblogs.com/cnblogs_com/suoning/845162/o_ns.png" height="100%" width="100%"></div>
          </body>
          </html>

          Auto: 默認
          Default: 默認
          e-resize
          ne-resize
          nw-resize
          n-resize
          se-resize
          sw-resize
          s-resize
          w-resize
          Crosshair
          Pointer
          Move
          text
          wait
          help

          not-allowed

          13. transform、transition 動畫效果

          transform 轉換,變形

          • origin 定義旋轉基點(left top center right bottom 坐標值) transform-origin: 50px 50px; transform-origin: left;。
          • rotate 旋轉 transform:rotate(50deg) 旋轉角度可以為負數,需要先定義origin。
          • skew 扭曲 transform:skew(50deg,50deg) 分別為相對x軸傾斜,相對y軸傾斜。
          • scale 縮放 transform:scale(2,3) 橫向放大2倍,縱向放大3倍;transform:scale(2) 橫豎都放大2倍。
          • translate 移動 transform:translate(50px, 50px) 分別為相對x軸移動,相對y軸移動。
          <!DOCTYPE html>
          <html>
          <head>
              <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
              <title>nick</title>
              <meta charset="utf-8" />
              <style type="text/css">
                  div {
                      border: 1px solid black;
                      height: 30px;
                      width: 30px;
                      background-color: yellow;
           
                      /*transform-origin: 50px 50px;*/
                      transform-origin: left;
                      transform: rotate(50deg);
                      /*transform: skew(50deg,50deg);*/
                      /*transform: translate(50px,50px);*/
                      /*transform: scale(2);*/
                  }
              </style>
          </head>
          <body>
              <div></div>
          </body>
          </html>


          Transition 平滑過渡

          • transition-property: 變換的屬性(none(沒有屬性改變)、all(所有屬性改變)、具體屬性)
          • transition-duration: 變換持續時間
          • transition-timing-function: 變換的速率(ease:(逐漸變慢)、linear:(勻速)、ease-in:(加速)、ease-out:(減速)、ease-in-out:(加速然后減速)、cubic-bezier:(自定義時間曲線))
          • transition-delay: 變換延遲時間
          • transition: 縮寫
          #property 指定屬性對應類型
          
          1、color: 通過紅、綠、藍和透明度組件變換(每個數值單獨處理),如:background-color,border-color,color,outline-color等CSS屬性;
          
          2、length:真實的數字,如:word-spacing,width,vertical- align,top,right,bottom,left,padding,outline-width,margin,min-width,min- height,max-width,max-height,line-height,height,border-width,border- spacing,background-position等屬性;
          
          3、percentage:真實的數字,如:word-spacing,width,vertical- align,top,right,bottom,left,min-width,min- height,max-width,max-height,line-height,height,background-position等屬性;
          
          4、integer 離散步驟(整個數字),在真實的數字空間,以及使用floor()轉換為整數時發生,如:outline-offset,z-index等屬性;
          
          5、number真實的(浮點型)數值,如:zoom,opacity,font-weight等屬性;
          
          6、transform list。
          
          7、rectangle:通過x、 y、 width和height(轉為數值)變換,如:crop;
          
          8、visibility:離散步驟,在0到1數字范圍之內,0表示“隱藏”,1表示完全“顯示”,如:visibility;
          
          9、shadow:作用于color、x、y、和blur(模糊)屬性,如:text-shadow;
          
          10、gradient:通過每次停止時的位置和顏色進行變化。它們必須有相同的類型(放射狀的或是線性的)和相同的停止數值以便執行動畫,如:background-image;
          
          11、paint server (SVG):只支持下面的情況:從gradient到gradient以及color到color,然后工作與上面類似;
          
          12、space-separated list of above:如果列表有相同的項目數值,則列表每一項按照上面的規則進行變化,否則無變化;
          
          13、a shorthand property:如果縮寫的所有部分都可以實現動畫,則會像所有單個屬性變化一樣變化。
          #支持執行transition效果的屬性
          
          Property Name    Type
          background-color    as color
          background-position    as repeatable list of simple list of length, percentage, or calc
          border-bottom-color    as color
          border-bottom-width    as length
          border-left-color    as color
          border-left-width    as length
          border-right-color    as color
          border-right-width    as length
          border-spacing    as simple list of length
          border-top-color    as color
          border-top-width    as length
          bottom    as length, percentage, or calc
          clip    as rectangle
          color    as color
          font-size    as length
          font-weight    as font weight
          height    as length, percentage, or calc
          left    as length, percentage, or calc
          letter-spacing    as length
          line-height    as either number or length
          margin-bottom    as length
          margin-left    as length
          margin-right    as length
          margin-top    as length
          max-height    as length, percentage, or calc
          max-width    as length, percentage, or calc
          min-height    as length, percentage, or calc
          min-width    as length, percentage, or calc
          opacity    as number
          outline-color    as color
          outline-width    as length
          padding-bottom    as length
          padding-left    as length
          padding-right    as length
          padding-top    as length
          right    as length, percentage, or calc
          text-indent    as length, percentage, or calc
          text-shadow    as shadow list
          top    as length, percentage, or calc
          vertical-align    as length
          visibility    as visibility
          width    as length, percentage, or calc
          word-spacing    as length
          z-index    as integer


          鼠標放在以下圖片上,There will be a miracle:

          <!DOCTYPE html>
          <html>
          <head>
              <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
              <title>nick</title>
              <meta charset="utf-8" />
              <style type="text/css">
                  .img-see-2016-7-2 {
                      background-image: url("http://images.cnblogs.com/cnblogs_com/suoning/845162/o_sea.jpg");
                      background-size: 660px;
                      background-repeat: no-repeat;
                      height: 300px;
                      width: 600px;
          
                      transition-duration: 30s;
                      transition-timing-function: ease;
                      transition-property: background-size;
                  }
                  .img-see-2016-7-2:hover {
                      background-size: 2000px;
                  }
              </style>
          </head>
          <body>
              <div class="img-see-2016-7-2"></div>
          </body>
          </html>

          作者:suoning

          原文鏈接:https://www.cnblogs.com/suoning/p/5625582.html

          效的CSS寫法中的一條就是使用簡寫。通過簡寫可以讓你的CSS文件更小,更易讀。而了解CSS屬性簡寫也是前端開發工程師的基本功之一。今天我們系統地總結一下CSS屬性的縮寫。

          色彩縮寫

          色彩的縮寫最簡單,在色彩值用16進制的時候,如果每種顏色的值相同,就可以寫成一個:

          color:#113366  

          可以簡寫為

          color:#136  

          所有用到16進制色彩值的地方都可以使用簡寫,比如background-color、border-color、text-shadow、box-shadow等。

          盒子大小

          這里主要用于兩個屬性:margin和padding,我們以margin為例,padding與之相同。盒子有上下左右四個方向,每個方向都有個外邊距:

          margin-top:1px;  
          margin-right:1px;  
          margin-botton:1px;  
          margin-left:1px;  

          這四個值可以縮寫到一起:

          margin:1px 1px 1px 1px;  


          縮寫的順序是上->右->下->左。順時針的方向。相對的邊的值相同,則可以省掉:

          margin:1px;//四個方向的邊距相同,等同于margin:1px 1px 1px 1px;  
          margin:1px 2px;//上下邊距都為1px,左右邊距均為2px,等同于margin:1px 2px 1px 2px  
          margin:1px 2px 3px;//右邊距和左邊距相同,等同于margin:1px 2px 3px 2px;  
          margin:1px 2px 1px 3px;//注意,這里雖然上下邊距都為1px,但是這里不能縮寫。

          邊框(border)

          border是個比較靈活的屬性,它有border-width、border-style、border-color三個子屬性。

          border-width:數字+單位;

          border-style:none||hidden||dashed||dotted||double||groove||inset||outset||ridge||solid;

          border-color: 顏色 ;

          它可以按照width、style和color的順序簡寫:

          border:5px solid #369;  

          有的時候,border可以寫的更簡單些,有些值可以省掉,但是請注意哪些是必須的,你也可以測試一下:

          border:groove red; //大家猜猜這個邊框的寬度是多少?  
          border:solid; //這會是什么樣子?  
          border:5px; //這樣可以嗎?  
          border:5px red; //這樣可以嗎??  
          border:red; //這樣可以嗎???  

          通過上面的代碼可以了解到,border默認的寬度是3px,默認的色彩是black——黑色。默認的顏色是該規則中的color屬性的值,而color默認是黑色的(多謝 @birdstudio的提醒 )。border的縮寫中border-style是必須的。

          同時,還可以對每條邊采用縮寫:

          border-top:4px solid #333;  
          border-right:3px solid #666;  
          border-bottom:3px solid #666;  
          border-left:4px solid #333;  

          還可以對每個屬性采用縮寫:

          border-width:1px 2px 3px; //最多可用四個值,縮寫規則類似盒子大小的縮寫,下同  
          border-style:solid dashed dotted groove;  
          border-color:red blue white black;  

          outline

          outline類似border,不同的是border會影響盒模型,而outline不會。

          outline-width:數字+單位;

          outline-style:none||dashed||dotted||double||groove||inset||outset||ridge||solid;

          outline-color: 顏色 ;

          可以縮寫為:

          outline:1px solid red; 

          同樣,outline的簡寫中,outline-style也是必須的,另外兩個值則可選,默認值和border相同。

          背景(background)

          background是最常用的簡寫之一,它包含以下屬性:

          background-color:color||#hex||RGB(%||0-255)||RGBa;

          background-image:url();background-repeat:repeat||repeat-x||repeat-y||no-repeat;

          background-position:X Y|| (top||bottom||center) (left||right||center);

          background-attachment:scroll||fixed;

          background的簡寫可以大大的提高css的效率:

          background:#fff url(img.png) no-repeat 0 0;  

          background的簡寫也有些默認值:

          background:transparent none repeat scroll top left ; 

          background屬性的值不會繼承,你可以只聲明其中的一個,其它的值會被應用默認的。

          font

          font簡寫也是使用最多的一個,它也是書寫高效的CSS的方法之一。

          font包含以下屬性:

          font-style:normal||italic||oblique;

          font-variant:normal||small-caps;

          font-weight:normal||bold||bolder|| ||lighter|| (100-900);

          font-size: (number+unit) || (xx-small-xx-large);

          line-height:normal|| (number+unit);

          font-family:name,"more names";

          font的各個屬性也都有默認值,記住這些默認值相對來說比較重要:

          font-style: normal;  
          font-variant:normal;  
          font-weight: normal;  
          font-size: inherit;  
          line-height: normal;  
          font-family:inherit;  

          事實上,font的簡寫是這些簡寫中最需要小心的一個,稍有疏忽就會造成一些意想不到的后果,所以,很多人并不贊成使用font縮寫。

          不過這里正好有個小手冊,相信會讓你更好的理解font的簡寫:

          列表樣式

          可能大家用的最多的一條關于列表的屬性就是:

          list-style:none  

          它會清除所有默認的列表樣式,比如數字或者圓點。

          list-style也有三個屬性:

          list-style-type:none||disc||circle||square||decimal||lower-alpha||upper-alpha||lower-roman||upper-roman

          list-style-position:inside||outside||inherit

          list-style-image: (url) ||none||inherit

          list-style的默認屬性如下:

          list-style:disc outside none  

          需要注意的是,如果list-tyle中定義了圖片,那么圖片的優先級要比list-style-type高,比如:

          list-style:circle inside url(../img.gif)  

          這個例子中,如果img.gif存在,則不會顯示前面設置的circle符號。

          PS:其實list-style-type有很多種很有用的樣式,感興趣的同學可以參考一下:https://developer.mozilla.org/en/CSS/list-style-type

          border-radius(圓角半徑)

          border-radius是css3中新加入的屬性,用來實現圓角邊框。這個屬性目前不好的一點兒是,各個瀏覽器對它的支持不同,IE尚不支持,Gecko(firefox)和webkit(safari/chrome)等需分別使用私有前綴-moz-和-webkit-。更讓人糾結的是,如果單個角的border-radius屬性的寫法在這兩個瀏覽器的差異更大,你要書寫大量的私有屬性:

          -moz-border-radius-bottomleft:6px;
          -moz-border-radius-topleft:6px; 
          -moz-border-radius-topright:6px;
          -webkit-border-bottom-left-radius:6px;
          -webkit-border-top-left-radius:6px; 
          -webkit-border-top-right-radius:6px;
          border-bottom-left-radius:6px;  
          border-top-left-radius:6px;  
          border-top-right-radius:6px; 

          這個例子中,如果img.gif存在,則不會顯示前面設置的circle符號。

          PS:其實list-style-type有很多種很有用的樣式,感興趣的同學可以參考一下:https://developer.mozilla.org/en/CSS/list-style-type

          border-radius(圓角半徑)

          border-radius是css3中新加入的屬性,用來實現圓角邊框。這個屬性目前不好的一點兒是,各個瀏覽器對它的支持不同,IE尚不支持,Gecko(firefox)和webkit(safari/chrome)等需分別使用私有前綴-moz-和-webkit-。更讓人糾結的是,如果單個角的border-radius屬性的寫法在這兩個瀏覽器的差異更大,你要書寫大量的私有屬性:

          -moz-border-radius-bottomleft:6px;
          -moz-border-radius-topleft:6px; 
          -moz-border-radius-topright:6px;
          -webkit-border-bottom-left-radius:6px;
          -webkit-border-top-left-radius:6px; 
          -webkit-border-top-right-radius:6px;
          border-bottom-left-radius:6px;  
          border-top-left-radius:6px;  
          border-top-right-radius:6px;  

          呃,是不是你已經看的眼花了?這只是要實現左上角不是圓角,其它三個角都是圓角的情況。所以對于border-radius,強烈建議使用縮寫:

          -moz-border-radius:0 6px 6px;
          -webkit-border-radius:0 6px 6px; 
          border-radius:0 6px 6px;

          這樣就簡單了很多。PS:不幸的是,最新的Safari(4.0.5)還不支持這種縮寫… (thanks @fireyy)

          就總結這么多,還有其它的可以縮寫的屬性嗎?歡迎大家提出一起討論。

          參考資源

          常用CSS縮寫語法總結:

          www.w3cn.org/article/tips/2005/103.html

          CSS Shorthand Guide

          Efficient CSS with shorthand properties

          Mozilla Developer Center:CSS Reference

          CSS Font Shorthand Property Cheat Sheet

          近米谷愛上了整理的活,HTML標簽全稱對照,拿去?

          HTML標簽英文全稱中文釋義
          aAnchor
          abbrAbbreviation縮寫詞
          acronymAcronym取首字母的縮寫詞
          address Address地址
          dfn Defines a Definition Term定義定義條目
          kbd Keyboard鍵盤(文本)
          samp Sample示例(文本
          var Variable變量(文本)
          tt Teletype打印機(文本)
          codeCode源代碼(文本)
          prePreformatted預定義格式(文本 )
          blockquote Block Quotation區塊引用語
          cite Citation引用
          qQuotation引用語
          strongStrong加重(文本)
          em Emphasized加重(文本)
          bBold粗體(文本)
          iItalic斜體(文本)
          big Big變大(文本)
          small Small變小(文本)
          sup Superscripted上標(文本)
          sub Subscripted下標(文本)
          bdo Direction of Text Display文本顯示方向
          br Break換行
          center Centered居中(文本)
          font Font字體
          u Underlined下劃線(文本)
          s/ strike Strikethrough刪除線
          div Division分隔
          span Span范圍
          ol Ordered List排序列表
          ul Unordered List不排序列表
          liList Item列表項目
          dl
          Definition List
          定義列表
          dt Definition Term定義術語
          dd Definition Description定義描述
          del Deleted刪除(的文本)
          ins Inserted插入(的文本)
          h1~h6Header 1 to Header 6標題1到標題6
          pParagraph段落
          hr Horizontal Rule水平尺
          hrefhypertext reference超文本引用
          altalter替用(一般是圖片顯示不出的提示)
          srcSource源文件鏈接
          cellcell
          cellpaddingcellpadding巢補白
          cellspacingcellspacing巢空間
          nlnavigation lists導航列表
          trtable row表格中的一行
          thtable header cell表格中的表頭
          tdtable data cell表格中的一個單元格
          iframeInline frame定義內聯框架
          optgroupOption group定義選項組

          主站蜘蛛池模板: 污污内射在线观看一区二区少妇| 日产一区日产2区| 日韩aⅴ人妻无码一区二区| 成人乱码一区二区三区av| 肉色超薄丝袜脚交一区二区| 日本精品一区二区三区在线视频一| 91在线一区二区三区| 中文字幕在线精品视频入口一区 | 曰韩人妻无码一区二区三区综合部 | 精品在线一区二区三区| 精品国产aⅴ无码一区二区| 中文字幕一区二区免费| 国产精品无码一区二区在线观一 | 国产在线精品一区二区三区直播 | 视频一区二区三区在线观看| 亚洲综合无码一区二区痴汉| 97久久精品一区二区三区| 日本一区二区三区在线观看| 亚洲色精品aⅴ一区区三区| 一区二区三区免费看| 亚洲国产成人精品久久久国产成人一区二区三区综 | 精品乱人伦一区二区三区| 日本一区午夜艳熟免费| 亚洲永久无码3D动漫一区| 日本道免费精品一区二区| 中文字幕日韩人妻不卡一区| 2014AV天堂无码一区| 一区二区视频在线| 精品无码一区二区三区亚洲桃色| 日本内射精品一区二区视频| 91香蕉福利一区二区三区| 亚洲国产成人久久一区二区三区| 无码人妻一区二区三区一| 久久国产精品免费一区| 日本一区二区三区在线视频| 国产韩国精品一区二区三区 | 日韩精品乱码AV一区二区| 日韩av无码一区二区三区| 少妇一夜三次一区二区| 福利片福利一区二区三区| 国产福利电影一区二区三区,日韩伦理电影在线福 |