1. 程式人生 > >css基礎:樣式屬性

css基礎:樣式屬性

-h otto 下劃線 基礎 size out 去掉 滾動 ddl

1.背景與前景:background-color:;背景色,樣式表優先級高。

background-image:url(路徑);設置背景圖片

background-attachment:fixed;背景固定,不隨字體滾動。scroll;背景隨字體滾動。

background-repeat:no-repeat;不平鋪。repeat;平鋪。repeat-x;橫向平鋪。repeat-y;縱向平鋪。

background-position:center 背景圖居中,設置背景圖時,top 上,left 左,right 右,repeat必須為no-repeat

background-position:left 100px top 200px;離左邊100像素,離上邊200像素。

2.字體:font-famliy:"新宋體";

font-size:12px; 字體大小,需要加單位

font-weight:bold; 加粗,normal為正常。

font-style:italic; 斜體,normal不傾斜

color:#000000; 字體顏色

text-decoration:underline;下劃線,overline 上劃線,line-through刪除線,none 去掉下劃線

text-align:center; 水平居中,left 左對齊,right 右對齊

vertical-align:middle; 垂直對齊,top 頂部對齊,bottom 底部對齊

text-indent:28px; 首行縮進量

line-height:24px; 行高,一般為1.5~2倍字體大小。

display:none; 不顯示,inline-block 顯示為塊,不自動換行,高度可設。

visibility:hidden;可視性:隱藏,占空間;visible 顯示。

3.邊界和邊框:border 邊框線,margin 外邊距,padding 內邊距。

border:5px solid black;四邊框,5像素寬,實線,黑色。border-top 上邊框;bottom 下邊框;left 左;right 右。

margin:10px;四面邊框外寬度為10px;auto 居中;margin-top 頂部邊框外為10px;margin:20px 0px 10px 5px 上-右-下-左邊框外寬度分別為20,0,10,5px。

padding:10px:四面邊框內寬度為10px;上下左右同上。

3.列表與方塊:width、height、(top、bottom、left、right)只有在絕對坐標情況下才有用。

list-style:none;取消列表序號;circle 序號變為圓圈,樣式相當於無序。

list-style-image:url(圖片地址);圖片作為序號。

list-style-position:outside;序號在內容外;inside 序號跟內容在一起。

css基礎:樣式屬性