Search code examples
cssz-index

The length of first tab persists to be active


My first tab longer than second one. In first tab there are links and images with anchor link.The problem is first tab's links are still active although I click on second tab and lays down on my tag cloud, so prevent them to be clickable. I would like to know why links of first tab are still clickable althoug they are not appearing?

fiddle

HTML

<section class="tabs">
            <input id="tab-1" type="radio" name="radio-set" class="tab-selector-1" checked="checked" />
            <label for="tab-1" class="tab-label-1">About</label>

            <input id="tab-2" type="radio" name="radio-set" class="tab-selector-2" />
            <label for="tab-2" class="tab-label-2">Services</label>

            <input id="tab-3" type="radio" name="radio-set" class="tab-selector-3" />
            <label for="tab-3" class="tab-label-3">Work</label>


            <div class="clear-shadow"></div>

            <div class="tab-content">
                <div class="content-1">
                    <a href="#">Link</a>
        <a href="#" class="tab-thumb thumbnail" rel="bookmark" title="testing editor styles">
        <img src="#"  width="250" height="250"/></a>
        <a href="#">Link</a>
        <a href="#" class="tab-thumb thumbnail" rel="bookmark" title="testing editor styles">
        <img src="#" width="250" height="250"/></a>
        <a href="#">Link</a>
        <a href="#" class="tab-thumb thumbnail" rel="bookmark" title="testing editor styles">
        <img src="#" width="250" height="250"/></a>
        <a href="#">Link</a>
        <a href="#" class="tab-thumb thumbnail" rel="bookmark" title="testing editor styles">
        <img src="#" width="250" height="250"/></a>

                </div>
                <div class="content-2">
                    <h2>Most Commented</h2>



                    </div>
            </div>
        </section>
  <a href="">Link</a>

CSS

    .tabs {
    position: relative;
    margin: 40px auto;
    width: 100%;
    height: auto;
}

.tabs input {
    position: absolute;
    z-index: 1000;
    width: 100px;
    height: 40px;
    left: 0px;
    top: 0px;
    opacity: 0;
    -ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";
    filter: alpha(opacity=0);
    cursor: pointer;
}
.tabs input#tab-2{
    left: 100px;
}
.tabs input#tab-3{
    left: 220px;
}
.tabs input#tab-4{
    left: 340px;
}

.tabs label {
    background: #5ba4a4;
    background: -moz-linear-gradient(top, #5ba4a4 0%, #4e8c8a 100%);
    background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#5ba4a4), color-stop(100%,#4e8c8a));
    background: -webkit-linear-gradient(top, #5ba4a4 0%,#4e8c8a 100%);
    background: -o-linear-gradient(top, #5ba4a4 0%,#4e8c8a 100%);
    background: -ms-linear-gradient(top, #5ba4a4 0%,#4e8c8a 100%);
    background: linear-gradient(top, #5ba4a4 0%,#4e8c8a 100%);
    font-size: 15px;
    line-height: 40px;
    height: 40px;
    position: relative;
    padding: 0 12px;
    float: left;
    display: block;
    width: 80px;
    color: #385c5b;
    letter-spacing: 1px;
    text-transform: uppercase;
    font-weight: bold;
    text-align: center;
    text-shadow: 1px 1px 1px rgba(255,255,255,0.3);
    border-radius: 3px 3px 0 0;
    box-shadow: 2px 0 2px rgba(0,0,0,0.1), -2px 0 2px rgba(0,0,0,0.1);
}

.tabs label:after {
    content: '';
    background: #fff;
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 100%;
    height: 2px;
    display: block;
}

.tabs input:hover + label {
    background: #5ba4a4;
}

.tabs label:first-of-type {
    z-index: 4;
    box-shadow: 2px 0 2px rgba(0,0,0,0.1);
}

.tab-label-2 {
    z-index: 3;
}

.tab-label-3 {
    z-index: 2;
}


.tabs input:checked + label {
    background: #fff;
    z-index: 6;
}

.clear-shadow {
    clear: both;
}

.tab-content {
    background: #fff;
    position: relative;
    width: 100%;
    height: auto;
    z-index: 5;
    box-shadow: 0 -2px 3px -2px rgba(0,0,0,0.2), 0 2px 2px rgba(0,0,0,0.1);
    border-radius: 0 3px 3px 3px;

}

.tab-content div {
    position: absolute;
    top: 0;
    left: 0;
    padding: 10px 40px;
    z-index: 1;
    opacity: 0;
    -webkit-display: flex;
    display: flex;
    -webkit-flex-flow: column;
    flex-flow: column;


    -webkit-transition: opacity linear 0.1s;
    -moz-transition: opacity linear 0.1s;
    -o-transition: opacity linear 0.1s;
    -ms-transition: opacity linear 0.1s;
    transition: opacity linear 0.1s;
}

.tab-content div img { border: 1px solid #903; position: relative;
}

.tabs input.tab-selector-1:checked ~ .tab-content .content-1,
.tabs input.tab-selector-2:checked ~ .tab-content .content-2,
.tabs input.tab-selector-3:checked ~ .tab-content .content-3 {
    z-index: 100;
  -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";
  filter: alpha(opacity=100);
  opacity: 1;
  -webkit-transition: opacity ease-out 0.2s 0.1s;
  -moz-transition: opacity ease-out 0.2s 0.1s;
  -o-transition: opacity ease-out 0.2s 0.1s;
  -ms-transition: opacity ease-out 0.2s 0.1s;
  transition: opacity ease-out 0.2s 0.1s;
  position:relative;
}
.tab-content div h2,
.tab-content div h3{
    color: #398080;
}
.tab-content div p {
    font-size: 14px;
    line-height: 22px;
    font-style: italic;
    text-align: left;
    margin: 0;
    color: #777;
    padding-left: 15px;
    font-family: Cambria, Georgia, serif;
    border-left: 8px solid rgba(63,148,148, 0.1);
}
.tab-content li {
  overflow: hidden;
  list-style: none;
  border-bottom: 1px solid #f0f0f0;
  margin: 0 0 8px;
  padding: 0 0 6px;
}

Solution

  • Because opacity:0 does make your div transparent but it is still there. Change opacity:0 to display:none insteed

    fiddle