標籤:
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基礎學習