我愿做如下 -分割一个div分成四个格
------------------------------------
| ------------- ------------- |
| | 1 | 2 | |
| | | | |
| ------------- ------------- |
| | 3 | 4 | |
| | | | |
| --------------------------- |
------------------------------------
到目前为止,我tried-
body,
html {
padding: 0;
margin: 0;
height: 100%;
width: 100%;
}
#top {
width: 100%;
background-color: red;
height: 15%;
}
#bottom {
width: 100%;
background-color: blue;
height: 85%;
}
.inner {
width: 49%;
height: 49%;
border: 1px solid black;
float: left;
}
<div id="top"></div>
<div id="bottom">
<div class="inner">1</div>
<div class="inner">2</div>
<div class="inner">3</div>
<div class="inner">4</div>
</div>
但所有inner
的div是左对齐。如何在bottom
div内水平对齐中心?
我不完全明白你的问题,但现在我感觉有些Flexbox的闻到这里;) – Stratboy
你能解释一下水平居中的意思吗? –
这里是小提琴这个:https://jsfiddle.net/nj6qfgxn/ – peszo