I am seeking a way to create a centered div with the left side filled with color, as shown in examples.
I have devised two solutions without using flexbox, but both seem somewhat like hacks.
body {
margin: 0;
padding: 0;
}
.header {
width: 100%;
height: 60px;
position: fixed;
}
.center-part {
width: 500px;
margin: 0 auto;
height: inherit;
background-color: rgba(0,255,0,0.8);
position: relative;
}
.blue-big {
background-color: blue;
width: 9999px;
height: inherit;
position: absolute;
right: 500px;
}
.equal-side {
display: table-cell;
}
<div class="header" style="top: 0px">
<div class="center-part">
<div class="blue-big">
</div>
</div>
</div>
<div class="header" style="top: 70px; display: table;">
<div class="equal-side" style="background-color: blue">
</div>
<div class="center-part" style="display: table-cell;">
</div>
<div class="equal-side">
</div>
</div>
The first solution involves a large div and positioning, while the second one relies on "display: table".
I am uncertain if either of these approaches is considered best practice or if there is a better way to achieve this layout?
The green DIV will not completely fill the height, ruling out the option of placing a div in the background with 50% width.