1.Div左右居中

1
div{ width;300px;height:300px;margin:0 auto; }
登录后复制

2.Div上下左右居中

.son{position:absolute;top:50%;left:50%;width:300px;heigeht:300px; margin-top:-150px; /*等于高度的一半*/margin-left:-150px; /*等于宽度的一半*/}
登录后复制

3.背景图片上下左右居中

background-position:center;
登录后复制

4.边框变成小三角
得到一个 宽为10px,黑色向下的小三角,背景色为红色

div{
width:0;
height:0;
border:10px solid red;
border-top-color:black;
}
登录后复制

5.关于换行

white-space:nowrap;/*不换行*/
white-space:normal;/*换行*/
登录后复制

6.关于margin-top的传递问题
为其父元素加上边框,就可以解决

7.清除默认样式

body,h1,h2,h3,h4,h5,h6,dl,dd,p{marhon:0;}
ul,ol{margin:0; padding:0;}
th.td{padding:0;}
登录后复制

8.表格



table{border-collapse:collapse;}
跨行合并:rowspan;
跨列合并:colspan;
登录后复制

9.表单

/*for和id相同*/
登录后复制

10.清除浮动

.clearfix:after{
display:block;
content:'';
clear:both;
}
.clearfix{
zoom:1;  /* for IE6*/
}
登录后复制


09-18 11:14
man18
female28