I've got a header/logo with div blocks on the right and left:
.wrap .title-area {
position: absolute;
top: 0;
width: 100%
}
<div class="wrap">
<div class="header-left-box">
<p>abcd-left box</p>
</div>
<div class="title-area">
<p>abcd-header</p>
</div>
<div class="header-right-box">
<p>abcd right box</p>
</div>
</div>
I styled it with 30%, 40%, 30% width and each has float:left to give the results I need. On reduced screen size, I give each div box 100% width so they stack. But because I want the logo box at the top, I give the style.
That brings the header to the top but the header-left-box also stays at the top, under the header. How can I arrange those as needed without them overlapping?
We can reorder HTML elements by using many methods in CSS. We use flexbox's order property. Order property is used to change the visual order and not their logical order. Items in a container are sorted in ascending order value and then by their source code order.
row-reverse displays the elements in reverse order horizontally, while column-reverse displays the elements in reverse order vertically.
You can achieve this with flex
. For the reduced screen size you can use this aditionally
.title-area {
order: -1 //Move the title area above the others
}
.wrap {
display:flex;
flex-direction: column;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With