摘自
display declaration:
display: inline means that the element
is displayed inline, inside the
current block on the same line. Only
when it’s between two blocks does the
element form an ‘anonymous block’,
that however has the smallest possible
width.
您不能给出内联元素集的宽度或高度尺寸,它们将被忽略.元素必须具有显示类型的块才能执行此操作.然而,设置显示:块将无法实现您想要的效果,因为每个元素将填充整个宽度. float:left将导致它们向左堆叠并强制显示:block.
#wrap {
width:100%;
}
#wrap:after {
/* Prevent wrapper from shrinking height,
see http://www.positioniseverything.net/easyclearing.html */
content: ".";
display: block;
height: 0;
clear: both;
visibility: hidden;
}
#wrap .container {
float: left;
width:33%;
}
嗯,语义学
有关浮动的进一步评论,请参阅Phunky的回答.