一般html布局会用居中显示,这里需要注意的是,当元素设置了固定宽度之后,margin:0 auto才适用,如果设置了width为100%,则无效:

1
2
.wapper{ margin : 0  auto ;width  100% ; }  \\这是无效的
.wapper { margin : 0  auto ;width  750px ;}  \\这是正确的


float属性:一般float会对它自己后面的标签产生影响(只对它后面的标签影响),这时受影响的标签需要清除浮动。

  1. 1
    2
    clear: both ;     #只对float后面受影响的标签有效,但对父级标签无效。
    overflow: hidden ;  #对float后面的标签和父级标签都有效。


float还会影响父级标签,比如:

1
2
3
4
< div  class = "test" >
     < div  class = "test1" ></ div >
     < div  class = "test2" ></ div >
</ div >


这里如果test2设为float,则test2后面的标签和父级标签test都会受到影响。


position定位方式:

1
2
3
#静态定位
#相对定位
#绝对定位

可设置四个属性值:

1
2
3
4
static
relative
absolute
fixed


html a标签默认未点击的颜色为蓝色,点击过后为紫色,如何修改?

1
2
.nav a:link,.nav a:visited{color:green;text-decoration:none;}
.nav  a:hover,.nav a:actived{color:red;text-decoration:none;}