一、布局属性
width
描述:设置对象的宽度
语法:width:value;
height
描述:设置对象的高度
语法:height:value;
说明:只有块级对象、HTML中存在width、height属性的内联对象、图片有width和height属性。
overflow
描述:溢出的处理
语法:overflow:visible|hidden|scroll|auto;
其中:visible:可见溢出部分(默认)
hisdden:隐藏溢出部分(常用)
scroll:总是显示滚动条(滚动)
auto:溢出时才会显示滚动条(自动)
二、边框属性
border-top/left/right/bottom-width
描述:设置上/左/右/下边框的宽度
语法:border-top/left/right/bottom-width:value;
border-top/left/right/bottom-style
描述:设置上/左/右/下边框的线型
语法:border-top/left/right/bottom-style:none|solid(实线)|dotted(点划线);
border-top/left/right/bottom-color
描述:设置上/左/右/下边框的颜色
语法:border-top/left/right/bottom-color:value;
border-top/left/right/bottom
描述:设置上/左/右/下边框的属性
语法:border-top/left/right/bottom:width style color;
border
描述:设置边框的属性(四个边的属性相同)
语法:border:width style color;
三、内边距与外边距
3.1 外边距
margin-top/left/right/bottom
描述:设置上/左/右/下侧的外边距
语法:margin-top/left/right/bottom:value;
margin
(1)语法:margin:value(四个方向相同);
(2)语法:margin:上下 左右;
(3)语法:margin:上 左右 下;
(4)语法:margin:上 右 下 左;
3.2内边距
padding-top/left/right/bottom/left/right/bottom
描述:设置上/左/右/下侧的内边距
语法:padding-top/left/right/bottom/left/right/bottom:value
padding
描述:设置内边距
padding:value(四个边的值相同)
padding:上下 左右
padding:上 左右 下
padding:上 右 下 左
四、盒子模型(BoxModel)
对象的宽度 = 左侧外边距 + 左侧边框 + 左侧内边距 + 宽度 + 右侧内边距 + 右侧边框 + 右侧外边距
margin:0 auto;作用是使盒子居中。
五、背景属性
background-color
描述:设置背景颜色
语法:background-color:value;
background-image
描述:设置背景图像
语法:background-image:url(图像URL);
background-repeat
描述:设置背景图像的平铺方式
语法:background-repeat:no-repeat|repeat|repeat-x|repeat-y;
background-attachment
描述:设置背景图像的依附方式
语法:background-attachment:scroll|fixed;
scroll:表示背景和内容一起滚动
fixed:表示内容滚动,背景不动
background-position
描述:设置背景图像的位置
语法:background-position:水平 垂直;
水平:left|center|right|value
垂直:top|center|bottom|value;
说明:图像的坐标原点(0,0)位于文档的左上角。所以,水平向左移动为负值;垂直向上移动为负值。
background-position-x
描述:设置背景横坐标
语法:background-position-x:value;
background-position-X
描述:设置背景纵坐标
语法:background-position-Y:value;
background
描述:设置背景属性(用于组合设置背景)
语法:background:color url(图像URL) repeat …
六、浮动定位
标准文档流(正常文档流):HTML元素在浏览器显示的顺序由HTML标记的书写顺序决定如果为块级对象则垂直排列;如果为内联对象则水平排列。
float
描述:设置对象的浮动
语法:float:left|right|none;
说明:
A.对象浮动后,将脱离标准文档流。
B.float属性设置为left时,对象将尽量向左移动,直到父对象的边界或上一个浮动对象的边界为止。
C.当(所有)子对象在方向上存在浮动属性时,其父对象的高度将清除为零。
D.none为默认设置,不浮动。
clear
描述:清除浮动所带来的影响
语法:clear:left|right|both|none;
标准的清理浮动的方法
.clear:after{
display:block;
height:0;
content:”.”;
visibility:hidden;
clear:both;
}
.clear{
zoom:1;
}
七、显示方式
display
描述:设置对象的显示方式
语法:display:none|block|inline;
说明:
A.none为默认形式,不显示对象
B.block:将元素转化为块对象
C.inlne:将元素转化为内联对象
哪些对象为块级对象?
A.默认情况下,div,p,h1~h6,ul,li,ol等;
B.内联对象使用display:block;属性后;
C.对象使用float属性后;
八、列表属性
list-style
描述:去掉列表前的标识符号
语法:list-style:none;
list-style-image
描述:用图像作为列表前的标识
语法:list-style-image:url(图像URL);
list-style-type
描述:列表前使用预设标识符
语法:list-style-type:disc|circle|square|diecimal|lower-alpha|upper-alpha|none;
说明:
A.diecimal:表示阿拉伯数字
B.lower-alpha:表示小写英文字母
C.upper-alpha:表示大写英文字母
list-style-position
描述:设置列表前标识的排列格式
语法:list-style-position:outside|inside;
说明:
A.outside:表示标识符在文本外且文本不根据标识符对齐,是默认值。
B.inside:表示标识符在文本内且环绕,文本根据标识符对齐。
九、文本属性
color
描述:设置文本颜色
语法:color:value;
font-size
描述:设置字号
语法:font-size:value;
说明:
标题:16px~24px
正文:12px~16px
font-family
描述:设置字体类型
语法:font-family:value,value,…;
font-style
描述:文本倾斜
语法:font-style:italic|normal|oblique;
说明:
A.normal:正常字体,不倾斜,默认值
B.italic:斜体
C.oblique:对没有斜体变量的特殊字体倾斜
font-weight
描述:文本加粗
语法:font-weight:bold|normal|bolder|lighter;
说明:
A.bolder:比normal粗一点
B.lighter:比normal细一点
text-align
描述:设置文本水平对齐方式
语法:text-align:left|center|right;
text-decoration
描述:设置文本修饰线
语法:text-decoration:none|underline|line-through|overline|blink;
说明:
A.none为默认值,无修饰
B.underline:下划线
C.blink:闪烁
D.line-through:删除线
E.overline:上划线
text-indent
描述:首行缩进
语法:text-indent:value;
line-height
描述:设置行高
语法:line-height:value|normal;
说明:行高一般设置为1.5em~2em
text-shadow
描述:设置文本阴影和模糊效果
语法:text-shadow:color|value
说明:value有3种表现:水平长度,垂直长度,模糊作用的距离
text-transform
描述:设置文本中的大小写
语法:text-transform:none|capitalize|uppercase|lowercase;
说明:
A.capitalize:将每个单词首字母转换为大写,其他不变
B.uppcase:将所有单词转换为大写
C.lowercase:将所有单词转换为小写
text-verflow
描述:设置文本溢出时是否显示省略号(…)
语法:text-verflow:clip|ellipsis;
说明:
A.clip:不显示省略号,而是简单的裁切,去掉溢出部分,默认值。
B.ellipsis:当文本溢出时用省略号代替溢出部分。
word-spacing
描述:设置单词间的间隔
语法:word-spacing:normal|value;
cursor
描述:设置鼠标指针类型
语法:cursor:pointer|help|text|crosshair|wait;
说明:
A.pointer:手形
B.help:帮助
C.text:文本:
D.crosshair:十字光标
E.wait:等待
十、表格属性
vertical-align
描述:设置垂直对齐方式
语法:vertical-align:top|middle|bottom;
border-spacing
描述:单元格的外边框间距
语法:border-spacing:value;
boder-spacing:横向间距 纵向间距
border-collapse
描述:设置单元格框线是否合并
语法:border-collapse:separate|collapse;
说明:
A.separate:边框独立,不合并,默认值
B.collapse:相邻边框合并
empty-cells
描述:设置边框显示或隐藏
语法:empty-cells:show|hide;
十一、定位属性
position
描述:设置定位类型
语法:position:static|fixed|absolute|relative;
说明:
A.fixed,脱离正常文档流,其位置在页面是固定的,并且可以通过top、right、bottom、left进行控制。
B.absolute,脱离正常文档流,其位置可以通过top、right、bottom、left进行控制。位置不固定,随页面滚动。
C.relative,没有脱离文档流,在通过top、right、bottom、left进行位置控制时,其实只是在原始出现位置上发生偏移。在溢出时不会出现滚动条。
D.static:正常文档流分布,无特殊定位,默认值。
z-index
描述:设置Z轴叠放顺序
语法:z-index:value;
说明:value值大的元素会覆盖value值小的元素,且仅作用与position属性值为relative或absolute的元素。
opacity:value;
说明:适用于Chrome、 Firefox等浏览器,且value的值为0~1之间。
filter:alpha(opacity=value);
说明:适用于IE浏览器,且value的值为0~100之间。