Note that there are some explanatory texts on larger screens.

plurals
  1. POMaking a css toggle with radio buttons (using Foundation 4 )
    primarykey
    data
    text
    <p>I'm having this totally silly problem in a custom Foundation 4 form.</p> <p>What I'm trying to to is a pure CSS toggle where you can switch between "sale" and "rent". They need to be <code>radio buttons</code> but I don't want them to look like that, so I'm trying to follow <a href="http://www.onextrapixel.com/2013/07/31/creating-content-tabs-with-pure-css/" rel="nofollow">this example</a> to style them by hiding the <code>inputs</code> and making the <code>labels</code> look as simple <code>links</code>.</p> <p>The markup is like this:</p> <pre class="lang-html prettyprint-override"><code>&lt;form class="custom"&gt; &lt;input type="radio" name="switchRadio" id="sale" value="sale" checked="" class="no-custom"&gt; &lt;label for="sale"&gt;Sale&lt;/label&gt; &lt;input type="radio" name="switchRadio" id="rent" value="rent" class="no-custom"&gt; &lt;label for="rent"&gt;Rent&lt;/label&gt; &lt;!--more form elements--&gt; &lt;/form&gt; </code></pre> <p>I know that default markup for custom forms in Foundation is to have the <code>input</code> nested inside of the label but I can't do it that way because I can't target a checked <code>input</code> parent with CSS, but I can target its sibling. </p> <p>I've added the <code>no-custom</code> class because, as inputs are not visible, I don't need them to be pretty.</p> <p>So for some weird reason, the <code>label for="sale"</code> works fine, clicking the label checks the <code>input id="sale"</code>, but clicking the <code>label for="rent"</code> also checks the <code>input id="sale"</code>. Any ideas why?</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.
    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