DIV CSS 佈局教程網

您现在的位置: DIV+CSS佈局教程網 >> 網頁腳本 >  >> CSS入門知識 >> CSS特效代碼
CSS 基礎樣式入門:字體、文本、背景與邊框
編輯:CSS特效代碼     

學習 CSS 的第一步,就是掌握那些最基礎的樣式屬性。以下整理了幾大常見類別,並附上實際的代碼示範,幫助你快速上手。

基礎樣式分類

字體類:font-size、font-weight、font-style 等。

文本類:color、text-indent、letter-spacing、word-spacing、line-height、text-decoration(underline、overline、line-through)等。

背景類:background-color、background-image: url、background-repeat、border 等。

列表類:list-style 等,以及一系列邊框屬性。

實際代碼示範

HTML 部分:

<h1>我是一個H1</h1>

CSS 部分:

h1{
font-size: 88px;
font-family: microsoft Yahei;
font-style: italic;
color: red;
letter-spacing: 55px;
text-decoration: line-through;
}
為 h1 設定 88px 的微軟雅黑字體,顏色改為紅色,字間距調整為 55px,並加上刪除線。
<h2>baobao jiushi roujiamo</h2>
h2{
color: pink;
font-weight: 900;
word-spacing: 80px;
}
為 h2 設定粉色、900 的字體粗細以及 80px 的詞間距。

接著是一個帶背景圖的 div:

<div class="div1">

</div>
.div1{
background-image: url("Koala.jpg");
border: solid 1px #000;
width: 1200px;
height: 1200px;
background-repeat: no-repeat;
background-position: top right;
}
為 div 加上背景圖與黑色邊框,設定不平鋪,並顯示在框內的右上角。

自訂列表標誌:

<ul class="ul1">
<li>再見</li>
<li>再見</li>
<li>再見</li>
<li>再見</li>
<li>再見</li>
</ul>
.ul1{
list-style: none;
list-style-image: url("Koala.jpg");
}
移除清單預設標誌,並自訂一個圖片作為列表標誌。

多樣化邊框樣式:

<div class="div3">

</div>
.div3{
width: 1200px;
height: 3000px;
border-top-style: double;
border-bottom-style: dotted;
border-left-style: dashed;
border-right-style: double;
border-color: red;
background-image: url("Koala.jpg");
background-repeat: no-repeat;
background-position: top right;
}
為名為 div3 的元素設定 1200×3000px 的寬高,上邊為雙實線、下邊為點線、右邊為雙實線、左邊為虛線,邊框顏色為紅色,插入背景圖 Koala.jpg,不平鋪並顯示於框內右上角。
XML學習教程| jQuery入門知識| AJAX入門| Dreamweaver教程| Fireworks入門知識| SEO技巧| SEO優化集錦|
Copyright © DIV+CSS佈局教程網 All Rights Reserved