【发布时间】:2012-05-05 07:44:12
【问题描述】:
我在 IE6 中显示浮动段落和图像时遇到问题。不过,在 Opera 和 Firefox 中显示这些内容没有问题。我在一个容器中有三个 div。每个 div 都有自己的段落和图像,可以向左或向右浮动。为了让我达到理想的布局,我在大部分段落和图像上设置了负边距。
这是我对齐浮动的方式:
---- 容器的 CSS 代码 -----
.container {
clear:both;
background:url(images/content_bg.png) repeat-x scroll 0 0 transparent;
width:850px;
height:750px;
overflow:hidden;
margin:0 auto;
}
----- 第一个 div 的 CSS 代码 -----
.row1 {
float:left;
width:790px;
height:460px;
margin:5px 0 0 40px;
}
.pic1 {
float:right;
height:460px;
width:382px;
margin:-100px -50px 0 -60px;
}
h2, p {
font-family:Arial, Helvetica, sans-serif;
}
.row1 p {
font-size:12px;
text-indent:20px;
font-weight:bold;
text-align:justify;
margin:-10px -25px 0 0;
position:relative;
}
----------- 第二个 div 的代码 -------------
.ro2 {
float:left;
width:790px;
height:234px;
margin:-185px 0 0 28px;
position:relative;
}
.row2 p {
float:right;
font-size:12px;
font-weight:bold;
text-align:justify;
text-indent:20px;
margin:-195px 258px 0 175px;
position:relative;
}
.pic2 {
float:left;
}
--------- 第三个 div 的代码 ---------------
.row3 {
float:left;
width:790px;
height:203px;
margin:-10px 0 0 40px;
position:relative;
}
.row3 p {
float:left;
font-size:12px;
font-weight:bold;
text-indent:20px;
text-align:justify;
margin:-180px 265px 0 10px;
position:relative;
}
.pic3 {
float:right;
}
div 的高度(.row1 到 .row3)基于图像的高度,因此 div 可以同时包含段落和图片。在 IE6 中查看时,这些段落似乎与图像相距甚远。有些段落与其他图片重叠。
【问题讨论】:
-
你有任何我们可以看到的 html 吗?如果不知道你的元素是如何嵌套的,这很难说。