Here is a sample snippet:
.tabs {
display: flex;
position: relative;
}
.tab {
height: 100px;
background: lightgray;
}
.content {
position: absolute;
left: 0;
width: 100%;
height: 100%;
display: none;
background: lightgreen;
}
.open .content {
display: block;
}
.footer {
height: 50px;
background: lightblue;
}
<div class="tabs">
<div class="tab">
<div class="header">Tab 1</div>
<div class="content">Content 1</div>
</div>
<div class="tab open">
<div class="header">Tab 2</div>
<div class="content">Content 2</div>
</div>
</div>
<div class="footer">Footer</div>
The height of absolute positioned green content equals to the height of its relative positioned container. So it overlaps the footer. Is it possible to keep top position relative and to set bottom to 0? Something like:
.content {
position: absolute;
left: 0;
width: 100%;
top: relative; /* Not supported */
bottom: 0;
display: none;
background: lightgreen;
}
I can set top
explicitly, say, to 20px
. Or I can calculate and set it using JavaScript. Is there a CSS only solution without pre-calculated top
value?