布局/浮动的问题:左

时间:2013-07-19 12:40:42

标签: css css-float

我刚问了这个问题'trouble with unwanted space between divs'

现在我遇到了一个新问题...对于我的布局,我需要将此框倍增8次,如下所示:

之前有效,但是现在(在我擦除高度之后)我得到了这个:

enter image description here

这是一个小提琴:http://jsfiddle.net/m5t6e/ 这是代码:

HTML(重复8次):

<div class='image'></div>
<div class='line1'></div>
<div class='head'></div>
<div class='subBox'>
    <div class='sub'></div>
    <div class='price'></div>
    <div class='button'></div>
</div>
<div style='clear:both;'></div>
<div class='line2'></div>
<div class='placeholder'></div>

CSS:

.headerimage {
    background-color:#000;
    height:273px;
    left:0;
    position:absolute;
    right:0;
}
.box1 {
    position:relative;
    top:273px;
}
.produkt {
    float:left;
    height:318px;
    position:relative;
    width:224px;
}
.image {
    background-color:#afeeee;
    height:230px;
    position:relative;
    width:224px;
}
.line1 {
    background-color:#000;
    height:1px;
    position:relative;
    width:224px;
}
.head {
    background-color:#eee;
    height:25px;
    position:relative;
    width:224px;
}
.subBox {
    height:50px;
    position:relative;
    width:224px;
}
.sub {
    height:25px;
    position:relative;
    width:224px;
}
.price {
    background-color:#847077;
    float:left;
    height:20px;
    position:relative;
    width:160px;
}
.button {
    background-color:#6A5ACD;
    float:left;
    height:20px;
    position:relative;
    width:58px;
}
.line2 {
    background-color:#000;
    height:5px;
    padding-bottom:20px;
    position:relative;
    width:224px;
}
.placeholder{
    height:800px;
    width:800px;
    position:relative;
    padding-top:1000px;
}

1 个答案:

答案 0 :(得分:-1)

  1. 删除.placehodler CSS样式

  2. 将每个元素封装在div

  3. 将封装的div设置为float:left,行为类似于display:inline-block div

  4. 在每4个街区后插入<br>

  5. 检查此jsFiddle