我想创建一个2×2设置,由4个div元素组成.到目前为止,请参阅我的
fiddle我的测试,使用inline-block进行显示.我想分别在1和2的正下方有“div 3”和“div 4”.没有花车有没有办法做到这一点?
HTML:
<div class = "blocks"> div 1 </div> <div class = "blocks"> div 2 </div> <div class = "blocks"> div 3 </div> <div class = "blocks"> div 4 </div>
CSS:
.blocks { display: inline-block; border: solid 1px red; width: 100px; }
解决方法
将块放在容器div中,并给它一个固定的宽度.
.wrap{ width:210px; } <div class='wrap'> <div class = "blocks">div 1</div> <div class = "blocks">div 2</div> <div class = "blocks">div 3</div> <div class = "blocks">div 4</div> </div>