文字或元素的颜色 color: #000000; 背景颜色 background-color 背景图像 background-image 字体 font-family 文字大小 font-size 列表样式 list 鼠标样式 cursor 边框样式 border 内补白 padding 外边距 margin
边框宽度 : border-width : 5px; 上边宽度 : border-top-width : 5px; 左边宽度 : border-left-width : 5px; 右边宽度 : border-right-width : 5px; 底边宽度 : border-bottom-width : 5px; 边框颜色 : border-color : #000000;
上边颜色 : border-top-color : #000000;
边框样式 : border-style : double; 可替换 dashed; dotted; none; 上边样式 : border-top-style : solid; 左边样式 : border-left-style : inset;
右边样式 : border-right-style : ridge; 底边样式
: border-bottom-style : solid;
整体宽度 : width : 5px; 整体高度 : height : 5px;
溢出选项 : overflow : visible; 可替换 hidden; scroll; auto; 内侧边距 : padding : 5px; 上内边距 : padding-top : 5px; 外侧边距 : margin : 5px; 上外边距 : margin-top : 5px; 文字字体 : font-family : fantasy; 文字大小 : font-size : 12pt; 文字粗细 : font-weight : bold; 文字样式 : font-style : italic; 文字变量 : line-height : 110%;
清除属性 : clear : left; 可替换 right; both; none; 浮动属性 : float : left; 可替换 right; none;
水平排列 : text-align : left; 可替换 right; center; justify;
文本修饰 : text-decoration : underline; 可替换 overline; line-through; blink;
文本缩进 : text-indent : 5em; 文字间距 : letter-spacing : 5px;
underline overline; 字母间距 : word-spacing : 5px;
文本转换 : text-transform : capitalize; 可替换 lowercase; uppercase;
垂直排列 : vertical-align : baseline; 可替换 top; middle; bottom; text-top; text-bottom; super; sub; 3em; 30%;
背景图片 : background-image : url(tianyi.gif);
背景拉伸 : background-repeat : repeat; 可替换 repeat-x; repeat-y; no-repeat;
背景定位 : background-position : left; 可替换 right; top; left top; right bottom; 30% 50%; 附加属性 : background-attachment : fixed; 可替换 scroll;
显示属性 : display : none; 可替换 block; inline; run-in; compact; list-item; marker; 是否可见 : visibility : visible; 可替换 hidden;
资源定位 : position : static; 可替换 relative; absolute; fixed; 距离顶部 : top : 5px; 距离左边 : left : 5px; 距离右边 : right : 5px; 距离底边 : bottom : 5px; 优先等级 : z-index : 5;
鼠标指针 : cursor : crosshair; 可替换 default; pointer; move; text; wait; help; n-resize; s-resize; w-resize; e-resize; ne-resize; nw-resize; se-resize; sw-resize;
CSS 属 性 一 览 表
属 性 名 称 属性功能及其取值 用 法 说 明 与 范 例 颜色与背景类
color 设置文字颜色 #rgb #rrggbb
rgb(255,255,255)
rgb(100%,100%,100%) H1{color:red} H1{color:#f00} H1{color:#ff0000} H1{color:rgb(255,0,0)}
H1{color:rgb(100%,0%,0%)}
background-color 设置背景颜色,格式同上。 BODY{background-color:red} BODY{background-color:#f00} BODY{background-color:#ff0000} BODY{background-color:rgb(255,0,0)} BODY{background-color:rgb(100%,0%,0%)} background-image 设置背景图片,
url(imageURL) body{backround-image:url(back.jpg);} background-repeat 设置背景图片是否重复排列:
repeat-x(X轴重复排列); repeat-y(Y轴重复排列);
No-repeat(不重复排列) BODY{background-repeat:repeat-x;}
BODY{background-repeat:No-repeat;}
background-attachment 设定背景图片是否卷动,默认为卷动。 scroll(卷动)
fixed(不卷动) BODY{background-attachment:fixed;}
background-position 设定背景图片或背景颜色开始显示的位置,取值格式: top,buttom,left,right,center(用关键字) 70px 10px(用长度值)
50% 30%(用百分比) BODY{background-position:right top;} BODY{background-position:50px 10px;}
BODY{background-position:20% 50%;}
background 定义背景综合属性,不要求顺序,各属性值以空格分开。 BODY{background:#ffcc00 url(bg.jpg) fixed center} 字型类
font-family 设置字型属性,取值可以是任何字型名称,缺省为浏览器内定字型,可以设多个以逗号(,)分开,有空格的英文字型可用单引号或双引号括起来。 P{font-family:宋体,楷体,黑体,\"Time New Rom\";}
font-style 设定字型样式:Normal(正常),italic、objlique(斜体) P{font-style:italic;}
font-variant 取值:Normal(默认),small-caps(如果是中文字型则将字型缩小显示,如果是英文则全部改为较小的大写) H3{font-variant:small-caps;} font-weight 设定字体粗细,取值有:
Normal(默认),bold,lighter,border,100,200...900
由于浏览器支持程度不同,一般只用normal和bold两种属性。 P{font-weight:bold;} font-size 设定字体的大小;
绝对大小:xx-small,x-small,small,mediumlarge,x-large,xx-large; 相对大小:larger,smaller;
数字表示可用单位:磅(pt),像素(px),英寸(in),厘米(cm); 亦可用百分比表示。 H2{font-size:36pt;} P{font-size:200%;}
font 设定字型的综合属性,其顺序如下:
{font-style font-variant font-weight font-size /line-height font-family;} P{bold 12pt/14pt impact,Arial;} 文字类
letter-spacing 设定文字间距。 P{letter-spacing:5pt;} text-decoration 设定文字加上下划线、删除线等效果: none(无)
underline(下划线) overline(上划线)
line-through(删除线)
vertical-align 设定文字或图片垂直方向的对齐方式:
baseline:默认值 sub:下标 super:上标 top:垂直向上对齐 middle:垂直居中 bottom:垂直向下对齐。
text-transform 转换英文字母大小写:
none:默认值 capitalize:首字母大写 uppercase:所有英文字母大写 lowercase:所有英文字母小写。
text-align 设置文字的水平对齐方式:
left:左对齐 right:右对齐 center:水平居中 justify:左右对齐。
text-indent 设定标记元素内文字的首行缩进或配合margin-left属性设定首行凸排。 line-height 设定行高,声明方式有标准行高、固定值表示法、百分比行高、字型大小比例行高等。
列表类
list-style-type 有序列表的编号方式(供
none:无编号 decimal:阿拉伯数字 lower-roman:小写罗马数字 upper-roman:大写罗马数字 lower-alpha:小写英文字母 upper-alpha:大写英文字母。 list-style-type 无序列表的符号样式(供
none:无符号 disc:实心圆符号 circle:空心圆符号 square:实心方形符号。 list-style-image 无序列表的自定义符号样式: 格式:url(图片名称) UL{list-style-imag:url(dd.gif);} list-style-position 设置列表清单符号缩排属性:
outside:凸排 inside:缩排 UL{list-style-imag:url(dd.gif); list-style-position:outside;}
list-style 列表清单项目的综合设定,属性之间用空格隔开。 UL{list-style-imag:url(dd.gif) inside;}
边界及其相关类
margin 标记元素边界值的综合设定。(其规则见右边范例)
亦可以用margin-top、margin-right、margin-bottom、margin-left分开设定各边的边界。 声明4个值,其顺序为上、右、下、左边界,如:DIV{margin:12pt 15pt 20pt 16pt;}
声明3个值,其顺序为上、右、下,缺少的左边界取其对边(右),如:DIV{margin:12pt 15pt 16pt;}
声明2个值,其顺序为上、右,缺少的下、左边界取其对边,如:DIV{margin:12pt 15pt;} 声明1个值,则4个边界同一个值,如:DIV{margin:15pt;}
padding 设定标记内容与标记边框之间的留白的综合设定(规则见margin属性的范例)。 也可分开设定padding-top、padding-right、padding-bottom、padding-left各值。
border-width 标记元素边框宽度的综合设定(规则类似于margin属性)。 也可分开设定border-top-width、border-right-width、border-bottom-width、border-left-width各值。 border-color 标记元素边框颜色的综合设定(规则类似于margin属性)。颜色取值见color属性。 也可分开设定border-top-color、border-right-color、border-bottom-color、border-left-color各值。
border-style 标记元素边框样式的综合设定(规则类似于margin属性)。边框样式有solid,double,goove,ridge,inset,outset等。 也可分开设定border-top-style、border-right-style、border-bottom-style、border-left-style各值。
border 标记元素4个边框的综合设定,可以分别声明边框宽度、边框样式、和边框颜色。 DIV{border:5pt solid #ff0000;} width 设定标记元素的宽度。 height 设定标记元素的高度。
float 设定标记元素与文字间的相对位置(文字绕排方式)。取值: none:以默认方式显示;
left:标记元素靠左,文字在右边绕排;
right:标记元素靠右,文字在左边绕排;
clear 设定标记元素与文字间的相对位置(与float不同的是标记元素两边都不绕排)。取值:
none:以默认方式显示;
left:标记元素靠左,右边无文字绕排;
right:标记元素靠右,左边无文字绕排; 其他类
z-index 设定标记元素的堆叠层次,取值为整数,也可以是负数,数值大的在上层。 visibility 设定标记元素是否可见,取值有:
inherit:取默认值 visible:可见 hidden:不可见(隐藏)
------------------------------------------------------------------------------------------------------
【長度單位】
CSS可使用長度單位 單位 單位說明 範例
pt Point,就像是Word裡面的Point一樣大小 font-size:10pt px Pixels,依您螢幕解析度而決定大小 font-size:10px
pc Pica,6個Pica是一英吋 font-size:10pc
mm 公厘,用過尺...這個設定值完全不會因為其他設定而改變 font-size:10mm cm 公分,不會因為使用者設定而改變 font-size:10cm
% 百分比,大部分是指所在位置寬度或者長度百分比 font-size:10%
--------------------------------------------------------------------------------
【顏色表示】
CSS可用顏色表示方式
表示方式 表示方式說明 範例
#rrggbb 可以用Windows色彩選擇工具找到 color:#feefc7
rgb(#,#,#) 用數字來表示紅色藍色以及綠色的混合...也可以用Windows色彩選擇工具找 color:rgb(135,255,124)
rgb(%,%,%) 用百分比來代表紅色藍色以及綠色的強度來混合顏色 color:rgb(70%,35%,41%) 顏色名稱 用顏色的名稱來指定顏色 color:brown
--------------------------------------------------------------------------------
【背景可用值】
CSS可用背景值
名稱 說明 可能值 範例
background 背景 下面的背景設定值皆適用 background:fixed
background-attachment 背景圖性是否固定 fixed, scroll background-attachment:fixed background-color 背景顏色 顏色
transparent(透空) backgroun-color:yellow background-image 背景圖片 none(無背景圖)
url(****)(圖片位置) background-image:url(test.jpg)
background-position 背景圖位置 水平 垂直 background-position:135 159 background-repeat 背景是否重複 repeat(重複) repeat-x(水平重複) repeat-y(垂直重複)
no-repeat(不重複) background-repeat:repeat
--------------------------------------------------------------------------------
【屬性可用值】
CSS可用屬性值
名稱 說明 可能值 範例
visibility 顯示或是隱藏 inherit(父元件決定) hidden(隱藏) visible(顯示)
visibility:hidden
width 寬度 auto(自動決定) 數字 width:135
height 高度 auto(自動決定) 數字 height:100
z-index Z軸高度(立體,是否在另一個元件之上) auto(自動決定) 數字 z-index:135
position 定位方式 absolute
(絕對定位-依視窗座標,原點為父視窗左上角)
relative
(相對定位-以一般網頁排列[right.center.left]後再根據座標定位,原點為定位後的位置) static
(靜態定位-以一般網頁排列) position:absolute
top(物件的position屬性須為absolute或relative) 物件的Y座標(原點根據postion屬性有所不同) 數字
left(物件的position屬性須為absolute或relative) 物件的X座標(原點根據postion屬性有所不同) 數字
--------------------------------------------------------------------------------
【文字設定可用值】
CSS可用文字設定值
名稱 說明 可能值 範例
font 文字設定 以下所有皆可使用
font:arial
font-family 字體 字體名稱 font-family:arial
font-size 字體大小 百分比或是數字(單位) font-size:12px
font-style 字型樣式 normal(普通)
italic(斜體)
oblique(斜體) font-style:italic
font-variant 字型特別樣式 normal(普通)
small-caps(大小英文字母) font-variant:small-caps font-weight 字型粗細 normal(普通) bold(粗體) bolder(超粗體) lighter(細體)
數字(400=normal 700=bold ) font-weight:bolder letter-spacing 字元相距 normal(普通) 數字(預設為0) letter-spacing:5 text-align 字元對齊 left(左邊) right(右邊)
center(中間)
justify(左右平分) text-align:justify text-decoration 字元樣式 none(普通) underline(加底線)
no-underline(不加底線) blink(閃爍)
no-blink(不閃爍)
line-through(加刪除線)
no-line-through(不加刪除線) overline(加頂線)
no-overline(不加頂線) text-decoration:underline
--------------------------------------------------------------------------------
【表格設定】
CSS可用表格設定值 框線位置:(上-top.下-bottom.左-left.右-right) 名稱 說明 可能值 範例
border 表格邊框設定 以下所有皆可使用 border:green border-color
border-(框線位置)-color
邊框顏色 任何顏色表示方法 border-color:blue border-style
border-(框線位置)-style 邊框樣式 none(無邊框) dotted(點線) dashed(虛線) solid(實線) double(雙線)
groove(立體凹線)
ridge(立體凸線) inset(立體嵌入線)
outset(立體隆起線) border-style:dotted border-width
border-(框線位置)-width
邊框寬度 數字 border-width:5 padding 邊框補白 數字 padding:5
--------------------------------------------------------------------------------
【滑鼠設定】
CSS可用滑鼠游標設定值 名稱 說明 可能值 範例
cursor 游標圖示 auto(自動決定) default(預設值) crosshair(十字) hand(手形)
move(移動時的游標) help(有問號的游標) text(文字編輯的游標) wait(忙碌中的游標) w-resize(向左箭頭) e-resize(向右箭頭) n-resize(向上箭頭) ne-resize{向右上箭頭) nw-resize(向左上箭頭) s-resize(向下箭頭) se-resize(向右下箭頭)
sw-resize(向左下箭頭) cursor:hand
--------------------------------------------------------------------------------
【捲軸設定】
CSS可用捲軸列設定值 名稱 說明 可能值 範例
scrollbar-base-color 捲軸列主色調 顏色 scrollbar-base-color:#aaaaaa scrollbar-arrow-color 按鈕箭頭的顏色 顏色
scrollbar-arrow-color:#000000
scrollbar-face-color 移動棒的顏色 顏色 scrollbar-face-color:#ffee99
scrollbar-highlight-color 按鈕邊框內層左邊與上面的顏色及捲軸底部軌道網狀顏色(與track
同時使用網狀會消失) 顏色 scrollbar-highlight-color: #000000
scrollbar-3dlight-color 按鈕邊框外層左邊與上面的顏色 顏色 scrollbar-3dlight-color:#000000 scrollbar-darkshadow-color 按鈕邊框外層右邊與下面的顏色 顏色 scrollbar-darkshadow-color:#000000
scrollbar-shadow-color 按鈕邊框內層右邊與下面的顏色 顏色 scrollbar-track-color: #cccccc scrollbar-track-color 底部軌道顏色 顏色 scrollbar-track-color: #cccccc
因篇幅问题不能全部显示,请点此查看更多更全内容