I am trying to use this recepee to implement tabs without using JS or JQuery, pure CSS, but I am stuck. The goal is to show different content on click on some label, and change the label style. Now it shows labels as I want, but content of each div somehow shown over the label, not under. Also, I cannot make it change style. Could anybody help? Thanks. Sorry if the question looks stupid - I am just starting with html.
<div id="menu">
<label class="collapse" for="1">tab1</label> <input id="1" name="r" type="radio" />
<div>111111111111111111111</div>
<label class="collapse" for="2">tab2</label> <input id="2" name="r" type="radio"/>
<div>2222222222222222222222</div>
<label class="collapse" for="3">tab3</label> <input id="3" name="r" type="radio" />
<div>333333333333333333333</div>
</div>
my css:
#menu {
padding-left: 20px;
}
#menu label {
height: 30px;
background-color: #d1ecee;
width: 75px;
color: #2cb674;
font-size: 12px;
line-height: 30px;
text-align: center;
float: left;
position: relative;
margin-left: 2px;
display:block;
margin-right: 20px;
}
#menu label:before {
content: "";
position: absolute;
left: -20px;
width: 0;
height: 0;
border-top: 30px solid #d1ecee;
border-left: 20px solid transparent;
display:block;
}
#menu label:after {
content: "";
position: absolute;
right: -20px;
width: 0;
height: 0;
border-bottom: 30px solid #d1ecee;
border-right: 20px solid transparent;
}
#menu input {
display: none !important;
}
#menu input+* {
display: none !important;
}
#menu input:checked+* {
display: block !important;
}
#menu input:checked+label {
background-color: #2cb674;
color: white;
}
#menu input:checked+label:before {
border-top: 30px solid #2cb674;
}
#menu input:checked+label:after {
border-bottom: 30px solid #2cb674;
}
UPDATE:
this is the picture I have now due to absolute positioning of target div