1、首先如果两个元素要并在同一行,使用float最好两个都加浮动

2、IE6下双边距问题,当有块级元素浮动的时候,该元素的横向margin值会被放大为两倍,解决办法:给该元素加display:inline即可。

3、li的一些问题

a:如果有两列布局,我们仅仅给右边加有浮动,在IE6,7下会折行,解决办法:正如第一条建议一样,要并在同一行的元素,最好都加浮动,所以这里只要给左列的元素也加上左浮动。

b、IE6,7下LI内部的元素都浮动的话,li之间会有4px的间隙。解决办法:给li加vertical-align:top/middle.

这里乱入了一个vertical-align。索性讲讲他的作用吧。顾名思义是设置垂直对齐方式

<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>zwl-byself</title>
<style>
.wrap{height:200px;border:2px solid #000; text-align:center;}
.span1{ width:100px;height:200px;background:yellow; display:inline-block; vertical-align:middle;}
.span2{ width:200px;height:100px;background:blue; display:inline-block; vertical-align:middle;}
</style>
</head>
<body>
<div class="box">
	<span class="span1"></span>
    <span class="span2"></span>
</div>
</body>
</html>

  如上例,给一个元素里面的内容元素设置对齐方式,而且每一个元素都要加上vertical-align:top/middle/bottom.

4、ie6下最小高度问题,前面有用到font-size:0;来解决,但是只能解决到2px。给该元素加上overflow:hidden;更完美的解决方案。

posted on 2015-06-13 19:21  toodeep  阅读(192)  评论(0编辑  收藏  举报