Answer the question
In order to leave comments, you need to log in
How to center the central block?
Assembly
<div class="wrap">
<div class="left">left</div>
<div class="center">center</div>
<div>right</div>
</div>
.wrap {
display: inline-flex;
border-color: blue;
justify-content: space-between;
min-width: 300px;
position: relative;
}
.wrap:before {
content:"";
position: absolute;
left: 50%;
background: pink;
height: 100%;
z-index: -1;
width: 50%;
}
.left {width: 100px;}
.center {
align-items: center;
padding: 0 20px;
}
Answer the question
In order to leave comments, you need to log in
To place the .center exactly in the center of the .wrap style the .center like this:
.center {
position: absolute;
left: 50%;
transform: translate(-50%, 0);
}
.left {width: 100px;}
.right {
width: 50px;
margin-left: 50px;
}
.center {
align-items: center;
padding: 0 20px;
margin: 0 20px;
}
For the .center block to be in the middle, the .left and right blocks must have the same width.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question