I’m working with a tab built in css, some codes not working since I’m new in css.
Here’s the CSS:
input#ckTab{display: none;}
.tabs{width: 100%;}
button{position:relative;height:60px;background:#fff;cursor:pointer;}
.ct-box {text-align:left;}
.ct-box > div {display: none;}
.lblUk-a:focus-within ~ .ct-box .ct-a {display: block;}
.lblUk-b:focus-within ~ .ct-box .ct-b {display: block;}
.lblUk-c:focus-within ~ .ct-box .ct-c {display: block;}
.lblUk-d:focus-within ~ .ct-box .ct-d {display: block;}
.lblUk-e:focus-within ~ .ct-box .ct-e {display: block;}
And, HTML:
<div class="container">
<input type="checkbox" id="ckTab" name="ckTab" checked />
<div class="tabs">
<div class="lblUk">
<button class="lblUk-a">M/25</button>
<button class="lblUk-b">S/40</button>
<button class="lblUk-c">X/21</button>
<button class="lblUk-d">L/45</button>
<button class="lblUk-e">XL/50</button>
<div class="ct-box">
<div class="ct-a">a ct</div>
<div class="ct-b">b ct</div>
<div class="ct-c">c ct</div>
<div class="ct-d">d ct</div>
<div class="ct-e">e ct</div>
</div>
</div>
</div>
</div>
What I want is: when I click a tab (e.g M/25, etc) the content of each tabs appear (this is working), but when I click the label or the content of the opened tab, it hides. I want it keep showing.
The content of each of the tabs keep showing when I CLICK it. Here’s the fiddle: JsFiddle
2
Answers
With the code in my question, I got difficult to get it work as I wish. You, dale, then suggest to use checkbox.
Here's the fiddle: Jsfiddle
Note: I use JS to make it awesome.
adding the line below to you code will keep you tab if your mouse stays on it after clicking but moving outside of tab will hide it.
to do it correctly, you should either use javascript or try leveraging invisible checkboxes in your codes if you wanna stay with pure css.