0
Guys I created a simple tab system, using css,html and jquey. However I’m having a problem defining the width
flaps.
To make it easier to explain I’ll post the code here:
function corrige_altura() {
$('.tabs-container').css({
height: $('.tabs:checked + label + div').height() + 80
});
}
$(function(){
corrige_altura();
});
/* Container das ABAS */
.tabs-container {
position: relative;
top: 3px;
}
/* ABAS */
input.tabs {
display: none;
}
input.tabs + label + div {
width: 100%;
opacity: 0;
position: absolute;
border: 1px solid #d7d7d7;
top: 40px;
left: 0;
padding: 25px 10px 25px 10px;
}
input.tabs + label + div {
z-index: -1;
}
input.tabs:checked + label + div {
opacity: 1;
z-index: 1;
}
/* Labels */
input.tabs + label {
line-height: 40px;
padding: 0 20px;
float: left;
background: #484848;
color: #ffffff;
cursor: pointer;
margin-right: 1px;
}
input.tabs + label:hover {
color: #ffffff;
background: #fff;
}
input.tabs:checked + label {
color: #000;
background: #f1f1f1;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<table width="100%">
<td width="50px" bgcolor="#E6E6FA"> </td>
<td>
<div class="tabs-container">
<!-- ABA 1 -->
<input type="radio" name="tabs" class="tabs" id="tab1" checked>
<label for="tab1">aba1</label>
<div>
asdasdasd
</div>
<!-- ABA 2 -->
<input type="radio" name="tabs" class="tabs" id="tab2" >
<label for="tab2">aba2</label>
<div>
sadsad
</div>
</div>
</td>
<td width="50px" bgcolor="#E6E6FA"> </td>
</table>
Good to note that when defining:
input.tabs + label + div {width: 100%;}
The tabs are superimposing the table where it is, I want it to be 100% of the screen. But respecting the table where it is.
If anyone can help me I’d be very grateful.
I tried here, but the error still continues. follow link https://jsfiddle.net/nd31vLpb/
– Hugo Borges
@Hugoborges looks at the link I posted along with the answer
– Silvio Andorinha
perfect worked 100% very fought
– Hugo Borges
friend noticed only one thing, with that I lost a margin of 10px that had inside the tab, have to put her again?
– Hugo Borges
Margin on the side? Look at the observation that I added the answer so I can better understand the difference between the properties
margin
andpadding
@Hugoborges– Silvio Andorinha
no internal margin, but already solved, created a new div and assigns a margin. Follow the link: https://jsfiddle.net/nd31vLpb/2/
– Hugo Borges
@Hugoborges Beauty. Note: internal margin in css is known as
padding
– Silvio Andorinha
OK, thank you very much, without your help would not have solved. vlw and stay with God
– Hugo Borges