In a section element, I have 3 divs inside, and I am trying to horizontally center 'div 2'. The issue I am facing is that the adjacent divs are not the same size, so using "justify-content:center" is not effective.
I came across a solution here (under the title "Center a flex item when adjacent items vary in size"), but unfortunately, it does not work for my case.
Below is the relevant code snippet:
HTML
<section>
<div id="div1">DIV 1</div>
<div id="div2">DIV 2</div>
<div id="div3">DIV 3</div>
</section>
CSS
section{
display:flex;
position:relative;
}
#div1{
width:260px;
}
#div2{
position:absolute;
left:50%;
transform(translateX:-50%,0);
}
#div3{
margin-left:auto;
width:50px;
}
Also, you can find a demonstration on codepen.
The main objective here is to center 'div2' and align the other divs to the left and right edges, respectively.
Any assistance on this matter would be greatly appreciated.