I am working with a parent div
that has an unknown width, as it depends on calculations based on the screen size. There are 4 child div
s within the parent, all floated to be horizontally aligned. The 1st, 2nd, and 4th child elements have fixed widths, while the 3rd element should stretch to fill the remaining space in the parent div
.
I attempted using display:table;
for the parent and display:table-cell
for the children, but this approach did not yield the desired result. Despite trying width:auto
for the 3rd element, I was unable to achieve the intended layout.
<div class="parent">
<div class="first"></div>
<div class="second"></div>
<div class="third"></div>
<div class="fourth"></div>
</div>
Here is a basic CSS setup:
.parent
{
width: 100%;
display:table;
}
.first
{
width: 80px;
height: 80px;
float: left;
display: table-cell;
}
.second
{
width: 80px;
height: 80px;
float: left;
display: table-cell;
}
.third
{
height: 80px;
float: left;
display: table-cell;
}
.fourth
{
width: 80px;
height: 80px;
float: left;
display: table-cell;
}
Your assistance with this problem would be greatly appreciated.