I'm using a radio button to create tabs from CSS only. The problem I'm running into is that I can't figure out how to select the <label>
that references the radio button. I keep the labels separate from the content so that I can lay them out as tabs:
<div class="tab-labels">
<label for="tab-1">Tab 1</label>
<label for="tab-2">Tab 2</label>
<label for="tab-3">Tab 3</label>
</div>
The content panes are layed out below. The input button is kept inside the content div so that I can select it when the label is clicked. But, I can't go in reverse:
<div class="content-container">
<div class="tab details">
<input id="tab-1" type="radio" name="radio-set" class="tab-selector" checked="checked"/>
<div class="content">
<p>Some content 1</p>
</div>
</div>
<div class="tab details">
<input id="tab-2" type="radio" name="radio-set" class="tab-selector"/>
<div class="content">
<p>Some content 2</p>
</div>
</div>
<div class="tab details">
<input id="tab-3" type="radio" name="radio-set" class="tab-selector"/>
<div class="content">
<p>Some content 3</p>
</div>
</div>
</div>
What I'm trying to accomplish and my question for this issue would be: How can I change the label background color when the radio input is clicked given this layout?
I have provided a fiddle if you want to play with this live: http://jsfiddle.net/mjohnsonco/6KeTR/