Note that there are some explanatory texts on larger screens.

plurals
  1. POSelect label using CSS selector
    primarykey
    data
    text
    <p>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 <code>&lt;label&gt;</code> that references the radio button. I keep the labels separate from the content so that I can lay them out as tabs:</p> <pre><code>&lt;div class="tab-labels"&gt; &lt;label for="tab-1"&gt;Tab 1&lt;/label&gt; &lt;label for="tab-2"&gt;Tab 2&lt;/label&gt; &lt;label for="tab-3"&gt;Tab 3&lt;/label&gt; &lt;/div&gt; </code></pre> <p>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:</p> <pre class="lang-html prettyprint-override"><code>&lt;div class="content-container"&gt; &lt;div class="tab details"&gt; &lt;input id="tab-1" type="radio" name="radio-set" class="tab-selector" checked="checked"/&gt; &lt;div class="content"&gt; &lt;p&gt;Some content 1&lt;/p&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="tab details"&gt; &lt;input id="tab-2" type="radio" name="radio-set" class="tab-selector"/&gt; &lt;div class="content"&gt; &lt;p&gt;Some content 2&lt;/p&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="tab details"&gt; &lt;input id="tab-3" type="radio" name="radio-set" class="tab-selector"/&gt; &lt;div class="content"&gt; &lt;p&gt;Some content 3&lt;/p&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>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?</p> <p>I have provided a fiddle if you want to play with this live: <a href="http://jsfiddle.net/mjohnsonco/6KeTR/" rel="nofollow">http://jsfiddle.net/mjohnsonco/6KeTR/</a></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload