如何在屏幕上制作150x150的正方形div

Chr*_*ris 4 html tiling inline

*并在填充前一行时开始新行?
这应该工作但不适合我,
HTML:

<div id="squares">
<div id="1">
width:150px;
height:150px;
</div>
<div id="2">
width:150px;
height:150px;
</div>
<div id="3">
width:150px;
height:150px;
</div>  
</div>
Run Code Online (Sandbox Code Playgroud)

所以这在页面上建立了3个方框

CSS:

#squares {
display:inline;
background-color:#000000;
}
Run Code Online (Sandbox Code Playgroud)

css应该告诉他们排队并且是黑色的,以便我们可以看到它们,以便在他们是否在正确的地方时进行测量.
我需要添加任何东西吗?您能想到实现这一结果的任何不同方法吗?

jac*_*ers 5

HTML

<div id="squares">
    <div id="1"></div>
    <div id="2"></div>
    <div id="3"></div>
</div>?
Run Code Online (Sandbox Code Playgroud)

CSS

#squares div {
    /* these styles will let the divs line up next to each other
       while accepting dimensions */
    display: block;
    float: left;

    width: 150px;
    height: 150px;
    background: black;

    /* a small margin to separate the blocks */
    margin-right: 5px;
}
Run Code Online (Sandbox Code Playgroud)

使用的另一种方法float是使用inline-block样式:

display: inline-block;
zoom: 1;
*display: inline;
Run Code Online (Sandbox Code Playgroud)