Seeking a complex CSS result that may seem impossible.
Consider the following scenario:
<div class="div1">
<div class="div2">
<div class="div3">
<div class="div4"></div>
Hello World
</div>
</div>
</div>
div {
box-sizing: border-box;
outline: 1px solid rgba(0, 0, 0, 0.5);
}
.div1 {
background: rgba(255, 0, 0, 0.5);
}
.div2 {
width: 800px;
margin: 0 auto;
display: flex;
background: rgba(0, 255, 0, 0.5);
}
.div3 {
position: relative;
background: rgba(0, 0, 255, 0.5);
}
.div4 {
position: absolute;
left: 0;
top: 0;
right: 0;
bottom: 0;
background: rgba(255, 0, 255, 0.5);
}
The goal is to have .div4
touch the left edge of .div1
and the right edge of .div3
.
With position: relative;
on .div1
Interested in alternative solutions to achieve the same effect!