У меня есть основной div, который является position:relative;
, и дочерние элементы, которые являются абсолютным элементом. Я хочу центрировать их по горизонтали, но происходит что-то странное, я не понимаю.
Как я могу центрироватьсяабсолютный элемент по горизонтали с flex?любая идея с этим?
пример изображения
body{
background:tomato;
}
.block{
position:relative;
width:700px;
background:white;
padding:10px;
}
.block-item{
width:60px;
height:60px;
position:absolute;
display:flex;
align-items:center;
justify-content:center;
}
.block-item:nth-of-type(1){
left:0;
background:lightgreen;
}
.block-item:nth-of-type(2){
left:5%;
top:25px;
background:lightblue;
}
.block-item:nth-of-type(3){
left:10%;
background:lightgray;
}
<div id="main">
<div class="block">
<div class="block-item"></div>
<div class="block-item"></div>
<div class="block-item"></div>
</div>
</div>