Is there a way to create two div
elements like these?
Even if the gray area shrinks, the two
div
elements will remain visually consistent.While I can use
box-sizing: border-box;
andpadding: 50% 0;
in the red box, I need to include text in the blue box.
https://i.sstatic.net/jL8uO.jpg
.c {
padding: 10px;
background-color: gray;
overflow: auto;
margin: 0 0 10px 0;
}
.c1 {
width: 300px;
}
.c2 {
width: 200px;
}
.w {
width: 100%;
}
.w div {
float: left;
}
.i {
width: 50%;
height: 50px;
background-color: red;
}
.t {
width: 50%;
height: 50px;
background-color: blue;
}
<div class="c c1">
<div class="w">
<div class="i"></div>
<div class="t"></div>
</div>
</div>
<div class="c c2">
<div class="w">
<div class="i"></div>
<div class="t"></div>
</div>
</div>