css層疊樣式表

來源:互聯網
上載者:User

標籤:文本   滾動   wrap   cli   tom   ott   載入   ima   ...   

css的三種聲明方式
    1、行內樣式
        通過每個標籤都有的style屬性
        <div style="color:red;">黃衛星說沒有內容</div>
    2、內聯樣式
        通過在head裡寫style標籤,style標籤裡寫樣式
        <style>
            div {
                color:gold;
            }
            
        </style>
    3、外聯樣式
        通過link標籤來引入css代碼
        <link rel="stylesheet" type="text/css" href="1.css" />
    優先順序:
        網頁載入順序決定優先順序
        就近原則

 

 偽類別選取器(要按下面的順序避免出錯)
            a:link {
                color:red;
            }
            a:visited {
                color:pink;
            }
            a:hover {
                color:black;
            }
            a:active {
                color:blue;
            }

屬性選取器
            input [ type=text ]
  

單位
    px            像素
    %            百分比
    em            根據父級元素的尺寸
    rem            根據html的尺寸,例:2rem;就是兩個字型的大小;
    vw            視窗寬度的百分比
    vh            視窗高度的百分比

【注】css的優先順序對比,權重比精確定位更優先;

文本修飾:
              text-indent        文本縮排;例子: text-indent:2rem;

             text-shadow        文本陰影
                                        text-shadow:10px 10px 10px red;
                                              1、水平位移量    可以為負
                                              2、垂直位移量    可以為負
                                              3、陰影模糊值    不可以為負
                                              4、陰影部分顏色

  text-overflow    文本超出的顯示方式
        clip        超出部分截斷
        ellipsis    超出時顯示...
        【注】    要想讓他生效的話需要設定
                overflow:hidden;
                white-space:nowrap;
                還要給元素設定寬度

   line-height        行高   【注意】當行高與元素高度一樣時會使文本垂直置中

   vertical-align    對齊    經常用於設定圖片
        top            頂端對齊
        middle        中間對齊
        bottom        底端對齊

背景
    background-color        背景顏色
    background-image        背景圖片  background-image:url(./image/xxxx);
    background-attachment    背景圖片是否跟著捲軸滾動
        fixed    相對於視窗固定 (這個功能好像經常看到)
        scroll    隨滾動而滾動
    background-repeat        背景圖片是否平鋪
    background-position        背景圖片定位
        left right top bottom 百分比

【注】css的功能真的很強大好用(完)

 

css層疊樣式表

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.