我基本上想使用 css 和 html 来定位元素,以便它们占据它们适合的任何空间。所以我有一个网格状的结构,元素堆叠得很好。问题是我无法让小盒子在大盒子旁边填满。例如http://jsfiddle.net/9pk4J/1/
HTML:
<section id="cubes">
<div>
<article class="large"></article>
</div>
<div>
<article></article>
</div>
<div>
<article></article>
</div>
<div>
<article></article>
</div>
<div>
<article></article>
</div>
<div>
<article></article>
</div>
<div>
<article></article>
</div>
<div>
<article></article>
</div>
</section>
CSS:
#cubes {
font-size:0;
position: absolute;
max-width:670px;
}
#cubes div {
display:inline-block;
padding:3px;
}
#cubes div article.large {
cursor:pointer;
display:inline-block;
height:300px;
width:492px;
background-color:rgba(0,0,0,0.5);
overflow:hidden;
}
#cubes div article {
cursor:pointer;
display:inline-block;
height:150px;
width:160px;
background-color:rgba(0,0,0,0.5);
overflow:hidden;
}
我意识到有些方法可以命名特定元素并使用绝对定位将它们放置到位,但理想情况下,我希望仅使用 css 和 html 将它们垂直和水平放置到位。