CSS 快速参考

下面按字母顺序列出了所有的 CSS 属性和对应的 DHTML 特性(所谓 DHTML 特性是指在客户端脚本中引用该 CSS 属性时使用的名称),并对常用的属性作了较详细的说明,供读者在设计网页时参考。

CSS 属性

DHTML 特性

说明

background background 提供多个背景属性的组合。例如:BODY{background: no-repeat yellow left center url(./image/background.jpg)}
 background-attachment backgroundAttachment  指定特定 HTML 元素背景图案是否与内容一起滚动,取值为 scroll | fixed。默认值 scroll 表示背景图案随着内容一起滚动;fixed 表示背景图案静止,而内容可以滚动。例如:BODY{background-attachment:fixed}
background-color backgroundColor 指定特定 HTML 元素的背景颜色,取值为 transparent 或具体颜色值。例如,H1{background-color:gray}
background-image backgroundImage 指定特定 HTML 元素的背景图案,取值为none | url(imageurl)(在指定其他有关背景图案的属性时,应先指定此属性)。例如,H1{background-image:url(./MM.jpg)}
background-position backgroundPosition 指定特定 HTML 元素背景图案的位置,取值为由空格隔开的两个值,既可以使用关键字 left | center | right 和 top | center | bottom,也可以指定百分数值,或者指定以标准单位计算的距离。例如:BODY{ background-position:left center}
background-repeat backgroundRepeat 指定特定 HTML 元素背景图案是否重复,取值为 repeat | repeat-x | repeat-y | no-repeat
border border 一次性指定四个框线的宽度、样式和颜色。例如,H1{border:thin solid blue}
border-bottom borderBottom 指定边框底边的宽度、样式和颜色。例如,H1{border-top:thin solid blue}
border-bottom-color borderBottomColor 指定边框底边的颜色,取值可以是任意颜色值
border-bottom-style borderBottomStyle 指定边框底边的样式,取值可以是:none | dotted | dashed | solid |double | groove | ridge | inset | outset,默认值是 none
border-bottom-width borderBottomWidth 指定边框底边的宽度,取值可以是:thin | medium | thick 或长度值
 border-color  borderColor 设置边框的颜色,取值可以是任意颜色值。可以指定多个值,按上、右、下、左的顺序指定边框的颜色,如果指定了 2 或 3 个值,则未指定颜色的边框采用相对边框的颜色值
border-left borderLeft 指定边框左边的宽度、样式和颜色。例如,H1{border-left:thin solid blue}
border-left-color borderLeftColor 指定边框左边的颜色,取值可以是任意颜色值
border-left-style borderLeftStyle 指定边框左边的样式,取值可以是:none | dotted | dashed | solid |double | groove | ridge | inset | outset,默认值是 none
border-left-width borderLeftWidth 指定边框左边的宽度,取值可以是:thin | medium | thick 或长度值
border-right borderRight 指定边框右边的宽度、样式和颜色。例如,H1{border-right:thin solid blue}
border-right-color borderRightColor 指定边框右边的颜色,取值可以是任意颜色值
border-right-style borderRightStyle 指定边框右边的样式,取值可以是:none | dotted | dashed | solid |double | groove | ridge | inset | outset,默认值是 none
border-right-width borderRightWidth 指定边框右边的宽度,取值可以是:thin | medium | thick 或长度值
border-style borderStyle 设置边框的样式,取值可以是:none | dotted | dashed | solid |double | groove | ridge | inset | outset,默认值是 none。当取多个值时,也按上、右、下、左的顺序为四个边框设置不同的样式;如果指定了 2 或 3 个值,则未指定样式的边框采用相对边框的样式值
border-top borderTop 指定边框顶边的宽度、样式和颜色。例如,H1{border-top:thin solid blue}
border-top-color borderTopColor 指定边框顶边的颜色,取值可以是任意颜色值
border-top-style borderTopStyle 指定边框顶边的样式,取值可以是:none | dotted | dashed | solid |double | groove | ridge | inset | outset,默认值是 none
border-top-width borderTopWidth 指定边框顶边的宽度,取值可以是:thin | medium | thick 或长度值
bottom bottom 确定元素下方向的位置
clear clear 指定元素是否允许浮动元素在它旁边,取值可以是:none | left | right | both,默认值为none
 border-width borderWidth  此属性是设置 border-top-width、border-right-width、border-bottom-width、和border-left-width 的快捷方式(以此给定顺序,即上、右、下、左的顺序)。如果只给定一个值,则它应用于所有四个边框线。如果给定 2 或 3 个值,则未指定的边框采用与其相对边框的设置
clip clip 控制元素的剪切
color color 指定特定 HTML 元素内文本的显示颜色,取值为任何合法的颜色值。例如,以下定义都是正确的:H1.red {color:red}、H1.red {color:#F00}、H1.red {color:#FF0000}、H1.red {color:rgb(255,0,0)}、H1.red {color:rgb(100%,0,0)}
cursor cursor 控制鼠标指针的样式,取值可以是 auto | crosshair | default | hand | move | e-resize | ne-resize | nw-resize | n-resize | se-resize | sw-resize | s-resize | w-resize | text | wait | help。例如,P{cursor:hand}
display display 确定元素是否应绘制在页面上,取值可以是 block | inline | list-item | none
float styleFloat 指定元素在何处浮动,取值为:none | left | right,默认值为 none
font font 提供多个字体属性的组合,按以下顺序定义:font-weight,font-variant,font-style,font-size,line-height,属性可以省略。例如,P{font:italic 200% serif}
font-family fontFamily 描绘要使用的“字体”优先级序列,取值可以是字体名称,也可以是字体族名称,值之间用逗号分隔。例如:BODY{font-family:gill,helvetica,sans-serif}
font-size fontSize 指定所用字体的大小,取值为 xx-small | x-small | small | medium | large |x-large | xx-large | smaller | larger,或者是具体的长度值或百分比
font-style fontStyle 指定选定字体的样式,取值为 normal | italic | oblique,后两者表示斜体。例如:H4 {font-style: italic}
font-variant fontVariant 选择正常或小写变体,取值为 normal | small-caps
font-weight fontWeight 指定所用字体的粗细,取值为 normal | bold | bolder | lighter | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900
height height 指定元素的高度
left left 确定元素左方向的位置
letter-spacing letterSpacing 指定文本字母间的间距,取值为 normal 或具体的长度值。例如:P{letter-spacing:1mm}
line-height lineHeight 指定目标选项内文本的行高,取值可以是数字、长度或百分比,默认值是 normal。例如,DIV{line-height:1.5}
link link 控制链接的颜色
list-style listStyle 一次性指定列表项目标记的图片、类型和位置。例如,UL{list-style:url(./image/ball.gif) disc inside}
list-style-image listStyleImage 为列表指定图片作为项目标记,取值可以是none | url(imageurl)。例如,UL{list-style-image:url (./target.gif)}
list-style-position listStylePosition 指定列表项目标记的位置,取值可以是 inside 或 outside,默认值是outside
list-style-type listStyleType 指定列表项目标记的类型,取值可以是 disc | circle | square | decimal | lower-roman | upper-roman | lower-alpha | upper-alpha | none。例如,OL{list-style-type:lower-roman}
margin margin 指定边界宽度的简捷方式,可同时指定上、右、下、左(以此顺序)边界的宽度。如果只指定一个值,则四个方向都采用相同的边界宽度;如果指定了 2 或 3 个值,则没有指定边界宽度的边采用对边的边界宽度。例如,P{margin: 20px,0px}
margin-bottom marginBottom 设置底端边界的宽度,取值可以是长度、百分比或 auto
margin-left marginLeft 设置左端边界的宽度,取值可以是长度、百分比或 auto
margin-right marginRight 设置右端边界的宽度,取值可以是长度、百分比或 auto
margin-top marginTop 设置顶端边界的宽度,取值可以是长度、百分比或 auto
overflow overflow 控制元素内容越界时的处理
padding paddingTop 指定填充的简捷方式,可同时指定上、右、下、左四个方向(以此顺序)填充的宽度。如果只指定一个值,则四个方向都采用相同的填充宽度;如果指定了 2 或 3 个值,则没有指定填充宽度的边采用对边的填充宽度。例如,P{padding:0.25in, 0.1in}
padding-bottom width 设置底端填充,取值可以是长度和百分数,但不允许使用负值
padding-left paddingLeft 设置左端填充,取值可以是长度和百分数,但不允许使用负值
padding-right paddingRight 设置右端填充,取值可以是长度和百分数,但不允许使用负值
 padding-top paddingTop  设置顶端填充,取值可以是长度和百分数,但不允许使用负值
page-break-after pageBreakAfter 设置在元素后是否出现页分隔符
page-break-before pageBreakBefore 设置在元素前是否出现页分隔符
position position 确定元素的定位方式,取值可以是 static | relative | absolute,默认值为 static
right right 确定元素右方向的位置
text-align textAlign 指定目标选项内文本的对齐方式,取值是:left | right | center | justify。例如:P{text-align:justify}
text-decoration textDecoration 对文本施加修饰效果,取值为none | underline | overline | line-through | blink。例如,:link, :visited, :active{text-decoration:none}
text-indent textIndent 按指定数值缩进文本,取值可以是长度值或百分比,默认值是 0。例如,P{text-indent:.74cm}
text-transform textTransform 对文本进行大小写转换,取值为:capitalize|uppercase|lowercase|none,默认值是 none。capitalize 值指示所选元素中文本的每个单词的首字母为大写;uppercase 值指示所有的文本都为大写,lowercase 值指示所有文本都以小写显示。例如,P{text-transform:uppercase}
top top 确定元素上方向的位置
unicode-bidi unicodeBidi 确定与双向运算法则相关的嵌入层
vertical-align verticalAlign 确定垂直方向上的对齐,取值为 baseline | sub | super | top | text-top | middle | bottom | text-bottom 或百分比。例如,IMG{vertical-align:text-top}
visibility visibility 确定定位的元素是否可见,取值可以是 inherit | visible | hidden,默认值是 inherit
width width 指定元素的宽度
word-spacing wordSpacing 指定单词之间的额外间距,取值为 normal 或长度值
z-index zIndex 控制元素的堆叠,取值为整数,也可以是负数,数值越大,越在上层

----------[ HTML(CSS) ]----------

你可能感兴趣的:(CSS 快速参考)