css基礎學習

來源:互聯網
上載者:User

標籤:

css(Cascading style sheets):層疊樣式表

1.圖片替換技術

以下代碼錶示:點擊百度logo的圖片就會跳轉到百度首頁。

<style >    .baidu{
  /*寬高定義圖片的寬高*/ width:154px height:30px border: 1px solid black background: url(../...百度logo.png) no repeat overflow:hidden /*超出隱藏*/ } .baidu a{ line-height:200px display:block /*分區塊*/  }</style><body> <h1 class="baidu"> <a href="http://www.baidu.com">百度</a> </h1></body>

2.sprite圖(雪碧圖)

<style>/*以片大小要使用ps來量出其圖片的像素*/.sprite{/*定義圖片大小*/    width:100px    height:80px    background: url(../..圖片.jpg);    background-position:-10px -20px; /*使    圖片能移到定義圖片大小重合*/    }.sprite:hover{    background-position:-60px -30px;/*當滑鼠移入時候顯示另一張圖片*/  }</style><body><div class="sprite"></div></body>

3.背景

以下代碼錶示一張開始為紅色背景的圖片用20s的時間變成黑色背景的圖,並且在瀏覽器上一直重複。

<style>    .box{        width:300px        height:300px        background:red no repeat center;        animation: bian 20s infinite;         }    @key frames bian {        from{        background:red        }        to{       background:black }        }
  }
</style><body><div class="box"></div></body>

4.文本

<style>    .text{        color:green;        font-size: 40px;        font-family: Fangsong;        font-weight:400;        font-style: litalic;        text-indent: 30px; /*文字縮排*/        letter-spacing: 10px; /*字間距*/        word-spacing: 10px; /*詞間距*/        line-height: 20px;        text-decoration: underline;    }    .text1{        text-transform:capitalize /*文本英文首字母大寫*/    }</style><body>    <p class="text">學習 web 前端</p>    <p class="text1">learn web</p></body>

 

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.