后是什么样子: 父块不缩水孩子包裹
但我想它喜欢这个LOOK,而无需使用Flexbox的:
这里的codepen
CODE:
#one {
background-color: grey;
text-align: center;
}
#two {
display: inline-block;
text-align: left;
padding: 10px;
background-color: lightgrey;
}
.square {
display: inline-block;
width: 300px;
padding-bottom: 300px;
background-color: black;
}
<div id="one">
<div id="two">
<div class="square"></div>
<div class="square"></div>
<div class="square"></div>
</div>
</div>
你想要浅灰色的盒子在灰盒子里面吗? – Roysh
@Roysh,我想要黑色的方块像我张贴的第三张图片那样居中。父母div的背景颜色对我无关紧要。 –
试试这个小提琴https://jsfiddle.net/gj2ub837/ – Roysh