1611 shaares
17 private links
17 private links
2 results
tagged
positioning
position: absolute;
margin-left: auto;
margin-right: auto;
left: 0;
right: 0;
Not only that, we can do one better by using vw
and calc
.
Simply set the width of the child elements to be 100% of the viewport width by using vw
(percentage viewport units), and then set their left margin to a negative calculated value based on this, minus the width of the wrapper. Other than the optional max-width
of the parent, everything else is calculated automatically. You can dynamically change the width of the parent container, and the children will automatically resize and align as needed, without being positioned.