css - Empty space between tab and content -
i want display contents of each tab. there empty space.
there no free space in first tab exists in other tabs. want remove gap
how fix problem? (please not suggest java script code.)
the following figure shows problem
there empty space between tab , content
.tab-caption:nth-of-type(1) { background-color: #ffaaaa; } .tab-caption:nth-of-type(2) { background-color: #aaffaa; } .tab-caption:nth-of-type(3) { background-color: #aaaaff; } .tab-content:nth-of-type(1) { background-color: #ffaaaa; } .tab-content:nth-of-type(2) { background-color: #aaffaa; } .tab-content:nth-of-type(3) { background-color: #aaaaff; } .tab-status { display: none; } .tab-status ~ .tab-caption-container { display: flex; } .tab-status ~ .tab-caption-container > .tab-caption { opacity: 0.4; cursor: pointer; } .tab-status:nth-of-type(1):checked ~ .tab-caption-container > .tab-caption:nth-of-type(1) { opacity: 1; } .tab-status:nth-of-type(2):checked ~ .tab-caption-container > .tab-caption:nth-of-type(2) { opacity: 1; } .tab-status:nth-of-type(3):checked ~ .tab-caption-container > .tab-caption:nth-of-type(3) { opacity: 1; } .tab-status ~ .tab-content-container > .tab-content { width: 100%; transform: translate(-100%); transition: 1s; } .tab-status:nth-of-type(1):checked ~ .tab-content-container > .tab-content:nth-of-type(1), .tab-status:nth-of-type(2):checked ~ .tab-content-container > .tab-content:nth-of-type(2), .tab-status:nth-of-type(3):checked ~ .tab-content-container > .tab-content:nth-of-type(3) { transition: 1s; transform: translate(0%); transition-delay: 1s; } .tab-content-container { overflow: hidden; width: 100%; height: auto; border: 1px solid #ccc; float: left; }
<input class="tab-status" id="tabswitch01" type="radio" name="tab" checked="checked"> <input class="tab-status" id="tabswitch02" type="radio" name="tab"> <input class="tab-status" id="tabswitch03" type="radio" name="tab"> <div class="tab-caption-container"> <label class="tab-caption" for="tabswitch01">tab1</label> <label class="tab-caption" for="tabswitch02">tab2</label> <label class="tab-caption" for="tabswitch03">tab3</label> </div> <div class="tab-content-container"> <div class="tab-content">tab1-data<br></div> <div class="tab-content">tab2-data<br>tab2-data<br></div> <div class="tab-content">tab3-data<br>tab3-data<br>tab3-data<br>tab3-data<br>tab3-data<br>tab3-data<br>tab3-data<br>tab3-data<br>tab3-data<br></div> </div>
i changed css .tab-content
such height animated also. removed float .tab-content-container
since didn't have purpose.
.tab-caption:nth-of-type(1) { background-color: #ffaaaa; } .tab-caption:nth-of-type(2) { background-color: #aaffaa; } .tab-caption:nth-of-type(3) { background-color: #aaaaff; } .tab-content:nth-of-type(1) { background-color: #ffaaaa; } .tab-content:nth-of-type(2) { background-color: #aaffaa; } .tab-content:nth-of-type(3) { background-color: #aaaaff; } .tab-status { display: none; } .tab-status~.tab-caption-container { display: flex; } .tab-status~.tab-caption-container>.tab-caption { opacity: 0.4; cursor: pointer; } .tab-status:nth-of-type(1):checked~.tab-caption-container>.tab-caption:nth-of-type(1) { opacity: 1; } .tab-status:nth-of-type(2):checked~.tab-caption-container>.tab-caption:nth-of-type(2) { opacity: 1; } .tab-status:nth-of-type(3):checked~.tab-caption-container>.tab-caption:nth-of-type(3) { opacity: 1; } .tab-status~.tab-content-container>.tab-content { width: 100%; transform: translate(-100%); transition: 1s; height: 0; } .tab-status:nth-of-type(1):checked~.tab-content-container>.tab-content:nth-of-type(1), .tab-status:nth-of-type(2):checked~.tab-content-container>.tab-content:nth-of-type(2), .tab-status:nth-of-type(3):checked~.tab-content-container>.tab-content:nth-of-type(3) { transition: 1s; transform: translate(0%); transition-delay: 1s; height: 100%; } .tab-content-container { overflow: hidden; width: 100%; height: auto; border: 1px solid #ccc; }
<input class="tab-status" id="tabswitch01" type="radio" name="tab" checked="checked"> <input class="tab-status" id="tabswitch02" type="radio" name="tab"> <input class="tab-status" id="tabswitch03" type="radio" name="tab"> <div class="tab-caption-container"> <label class="tab-caption" for="tabswitch01">tab1</label> <label class="tab-caption" for="tabswitch02">tab2</label> <label class="tab-caption" for="tabswitch03">tab3</label> </div> <div class="tab-content-container"> <div class="tab-content">tab1-data<br></div> <div class="tab-content">tab2-data<br>tab2-data<br></div> <div class="tab-content">tab3-data<br>tab3-data<br>tab3-data<br>tab3-data<br>tab3-data<br>tab3-data<br>tab3-data<br>tab3-data<br>tab3-data<br></div> </div>
Comments
Post a Comment