我打了这个
#center-1, #center-2, #center-2, #center-3, #center-4,
#center-5, #center-6, #center-7, #center-8 { float: left; width:360px; }HTML:
<div id="centerColumn">
<div id="center-1"></div>
<div id="center-2"></div>
<div id="center-3"></div>
<div id="center-4"></div>
<div id="center-5"></div>
<div id="center-6"></div>
<div id="center-7"></div>
<div id="center-8"></div>
</div>它不能工作,为什么?
发布于 2011-10-27 13:26:49
从您的报告中猜测它“不起作用”,您可能只是因为没有内容、高度或填充而没有看到div。添加height:10px;或其他东西,以及一些背景- they will show up。
顺便说一下,在您的例子中有一个slightly easier way来编写这个选择器:
/* Select all <div>s in the #centerColumn */
#centerColumn div {
float: left;
width:360px;
/* Test to make divs appear */
background:#f00;
height:10px;
margin:1px;
}发布于 2011-10-27 14:17:49
您的div没有任何内容,这就是它们不可见的原因。要使它们可见,请在其中至少添加一个高度,或者向css规则添加 /min-height。
https://stackoverflow.com/questions/7911786
复制相似问题