I have 3 blocks, that I need to:
- The first block needs to be 200px wide and touch the left side.
- The second block is right after the first block and its right edge is at exactly 50% width of its container
- The third block just takes over whatever the space is left.
I made something similar in some game engine:
But how can I achieve it with css?
I don't want to nest the inner divs because they're playing the same role.
I tried this but it doesn't work :(
* {
box-sizing: border-box;
}
.wrapper {
width: 100%;
display: flex;
position: relative;
}
.wrapper > * {
height: 300px;
display block;
}
.wrapper > *:nth-child(1) {
background-color: salmon;
width: 200px;
}
.wrapper > *:nth-child(2) {
background-color: khaki;
right: 50%;
}
.wrapper > *:nth-child(3) {
background-color: violet;
width: 50%;
}
<div class="wrapper">
<pre>
left: 0;
width: 200px;
</pre>
<pre>
left: 200px;
right: 50%;
</pre>
<pre>
left: 50%;
right: 0;
</pre>
</div>