常用CSS属性
- 格式:doc
- 大小:70.00 KB
- 文档页数:9
网页制作技术-网页设计中常用的CSS属性
文字或元素的颜色 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; underline overline;
line-through; blink;
文本缩进 : text-indent : 5em;
文字间距 : letter-spacing : 5px; 字母间距 : 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:所有英文字母小写。