How can I horizontally center the fixed element which has red border? I added 3 cubes for visual hint.
By center I mean that center cube is in viewport center (and stay there when viewport is resized) and rest of the fixed element is cut off from left and right if necessary.
This needs to be old-school, i.e no flexbox.
#element {
width: 120%;
height: 200px;
position: fixed;
left: 0;
top: 0;
border: 2px dashed #ec6161;
}
#children {
display: flex;
justify-content: space-around;
align-items: center;
height: 100%;
}
.child {
width: 50px;
height: 50px;
border: 2px dashed #888;
postion: absolute;
}
<div id="element">
<div id="children">
<div class="child left"></div>
<div class="child center"></div>
<div class="child right"></div>
</div>
</div>