-1
I am using the code below for a form with multiple "tabs", and I would like tabs 1-4 to appear above tabs 5-8, in two lines. However, tabs 1-4 appear normally, but tabs 5-8 are truncated, they do not appear at the bottom line as I would expect them to be "float".
You could help me change the code, so that tabs 5-8 appear below tabs 1-4, as in this image?
Here’s the code:
.nav_tabs{
width: 500px;
height: 400px;
margin: 5px 0;
position: relative;
}
.nav_tabs ul{
list-style: none;
}
.nav_tabs ul li{
float: left;
}
.tab_label{
display: block;
width: 100px;
background-color: #D8D8D8;
padding: 2px;
font-size: 16px;
color:black;
cursor: pointer;
border-right: solid 1px #A4A4A4;
text-align: center;
}
.nav_tabs .rd_tab {
display:none;
position: absolute;
}
.nav_tabs .rd_tab:checked ~ label {
background-color: #08298A;
color:#fff;
border: none;
}
.tab-content{
border-top: solid 5px #08298A;
background-color: #fff;
display: none;
position: absolute;
height: 300px;
width: 420px;
left: 40px;
}
.rd_tab:checked ~ .tab-content{
display: block;
}
<nav class="nav_tabs">
<ul>
<li>
<input type="radio" class="rd_tab" id="tab1" name="tabs" checked>
<label for="tab1" class="tab_label">ABA 1</label>
<div class="tab-content">
Conteúdo Aba 1
</div>
</li>
<li>
<input type="radio" class="rd_tab" id="tab2" name="tabs">
<label for="tab2" class="tab_label">ABA 2</label>
<div class="tab-content">
Conteúdo Aba 2
</div>
</li>
<li>
<input type="radio" class="rd_tab" id="tab3" name="tabs">
<label for="tab3" class="tab_label">ABA 3</label>
<div class="tab-content">
Conteúdo Aba 3
</div>
</li>
<li>
<input type="radio" class="rd_tab" id="tab4" name="tabs">
<label for="tab4" class="tab_label">ABA 4</label>
<div class="tab-content">
Conteúdo Aba 4
</div>
</li>
<li>
<input type="radio" class="rd_tab" id="tab5" name="tabs">
<label for="tab5" class="tab_label">ABA 5</label>
<div class="tab-content">
Conteúdo Aba 5
</div>
</li>
<li>
<input type="radio" class="rd_tab" id="tab6" name="tabs">
<label for="tab6" class="tab_label">ABA 6</label>
<div class="tab-content">
Conteúdo Aba 6
</div>
</li>
<li>
<input type="radio" class="rd_tab" id="tab7" name="tabs">
<label for="tab7" class="tab_label">ABA 7</label>
<div class="tab-content">
Conteúdo Aba 7
</div>
</li>
<li>
<input type="radio" class="rd_tab" id="tab8" name="tabs">
<label for="tab8" class="tab_label">ABA 8</label>
<div class="tab-content">
Conteúdo Aba 8
</div>
</li>
</ul>
</nav>
"In doing so, you won’t be able to change the visibility of content just by using CSS." - Not so, I posted an alternative that does just that. The secret is to separate the radiobuttons together, since the label for is "remote". Your idea is good, but the fact of maintaining the input with the label is that made it impossible.
– Bacco
@Bacco I thought about this possibility, but would not have to apply a style to the label associated to selected radio.
– Tobias Mesquita
the solution of this answer seems to have a bug, because when we click but bottom line tabs - "ABAS 5-8", the content does not exchange to "Contents Aba 5, 6, 7, 8.."
– Romulo Rocha
@Romulorocha corrected.
– Tobias Mesquita
Thanks @Tobiasmesquita got very good!
– Romulo Rocha