0

我需要让内容出现在 contentheader div 下方并包装 imagebox div 并且不与 imagebox div 重叠。p 内容应围绕 contentheader 和 imagebox。

这是它应该是什么样子的小提琴:http: //jsfiddle.net/NinjaSk8ter/nrJHP/

我的页面中有完全相同的代码,但是 p“内容”没有围绕 contentheader 和 imagebox“图像”:

http://www.northernvirginiapaintingcontractor.com/

这是标记:

    <div id="mid-feature">
    <div id="mid-featureleft" class="rounded">
        <div class="contentheader">
            <h1>Georgio Versari Painters & Artisans</h1>
        </div>
        <div class="imagebox">IMAGE
        </div>
        <p>Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content</p>
    </div>
    <div id="mid-featureright" class="rounded">

    </div>
    <div style="clear: both;">
    </div>
</div>

这是CSS:

#mid-feature {
width:925px;
margin:0 0 0 0;
position:relative;
/*overflow:hidden;*/  
/*background-color:Olive;*/
}
#mid-feature h1 {
color: #399DD6;
font-family: Arial;
font-size:17px;
}
/*#mid-feature p {
color: #0C2A55;
margin:29px 0 0 0;
position: absolute;
font-size:12px;
float: left;
z-index: 3;
line-height:14px; 
padding: 5px 5px 5px 5px;
}*/
#mid-featureleft {
height:250px;
width:609px;
margin: 12px 0 0 0;
float:left;
position:relative;
background-color:#E7EFF7;
}
#mid-featureleft p {
/*color: #0C2A55;*/
color:Red;
margin:0;
font-size:12px;
line-height:14px; 
margin-top: 27px;
padding: 5px 5px 5px 5px;
}
#mid-featureleft .contentheader {
height:29px;
width:286px;
text-align:left;
line-height:29px;
display: block;
float: left;
margin:0 0 0 0;
padding: 0 0 0 6px;
position:relative;
z-index: 1;
background-color:red;
}
#mid-featureleft .contentbox {
height:250px;
width:609px;
display: block;
float: left;
margin:0 0 0 0;
position:absolute;
background-color:blue;
}
#mid-featureleft .imagebox {
height:200px;
width:292px;
display: block;
float: right;
margin:0 0 0 317px;
position:absolute;
z-index: 2;
background-color:green;
}

如果有人能告诉我为什么这在 Fiddle 中有效,但在我的页面中无效,我将不胜感激。

4

2 回答 2

1

您的小提琴和您的代码之间有两个区别,这就是导致意外行为的原因。在您的#mid-featureleft .imagebox定义中,您正在添加一个position:absolute属性,这会导致绿色框覆盖文本。然后你有一个margin:0 0 0 327px属性将文本推到图像下方。

如果从 CSS 中删除这两个属性,则包装的行为与小提琴中的行为相同。

于 2012-07-25T20:56:45.013 回答
0

您应该从样式中获取marginposition属性。#mid-featureleft .imagebox

于 2012-07-25T20:57:40.737 回答