0

下面的链接显示了我正在处理的网站的简化版本以及我遇到的问题。

我有几个封装的盒子元素。有主容器,该容器中的几个 div 将保存内容,随着内容的扩展,我需要容器 div 自动扩展。除非我在 CSS 中添加特定高度,否则我似乎无法做到这一点。

JSFiddle 示例

HTML:

<body>
<div id="container">
    <div id="block1">
        <div id="one">one</div>
        <div id="two">two<br />two<br /></div>
        <div id="three">three<br />three<br />three<br /></div>
        <div id="four">four<br />four<br />four<br />four<br /></div>
    </div>
</div>
</body>

CSS:

#container {
width: 1050px;
margin: auto;
padding: 5px;
background-color: #ededf0;
background: 
   url("http://wguayan.comuv.com/brushed_metal_clear_apple.jpg") repeat;
}

#one, #two, #three, #four {
border-width: 1px;
border-color: black;
border-style: solid;
background-color: white;
border-radius:6px;
-moz-border-radius:6px;
/* Firefox 3.6 and earlier */
}

#one {
width: 100px;
position: relative;
top: 0px;
left: 0px;
padding: 10px;
box-shadow: 9px 9px 12px #888888;
}

#two {
float: left;
width: 100px;
position: relative;
top: 0px;
left: 0px;
padding: 5px;
text-align: center;
box-shadow: 9px 9px 12px #888888;
}

#three {
float: left;
width: 100px;
position: relative;
top: 0px;
left: 0px;
padding: 10px;
box-shadow: 9px 9px 12px #888888;
}

#four {
float: left;
width: 100px;
position: relative;
top: 0px;
left: 0px;
padding: 10px;
box-shadow: 9px 9px 12px #888888;
}

#block1 {
width: 100%;
border-width: 1px;
border-color: black;
border-style: solid;
}
4

1 回答 1

0

只需申请overflow: hidden#block1

于 2013-11-13T21:05:21.003 回答