Я сделал простой пример, чтобы проверить это. У меня есть одна оболочка div
с двумя другими элементами div
внутри, установленными на display: inline-block;
. Два внутренних элемента div
находятся на одной линии, но как мне расположить их по центру на половине основного div
, к которому они принадлежат? Например, синее поле в середине левой стороны основного div
и красное поле в середине правой стороны основного div
. Код и скриншот ниже.
![image](https://i.stack.imgur.com/a2RGt.png)
Also, the inspector shows a width of 204px for the main-box
div
and even when I set padding
and margin
to 0 there's still a gap on the bottom between the blue/red boxes and the border of the main-box
. How do I get rid of the gap?
.box-test {
height: 200px;
display: inline-block;
width: 30%;
box-sizing: border-box;
}
#blue {
background-color: blue;
}
#red {
background-color: red;
}
#main-box {
text-align: center;
border: 1px solid black;
}
<div id="main-box">
<div id="blue" class="box-test"></div>
<div id="red" class="box-test"></div>
</div>