Ahmed Nuaman


builder of internets ~ developer of dreams ~ tamer of Dachshunds

Fun with Radio Buttons

The humble radio button is a bit, well boring…

Look at it, all round and what not; Why not have some fun with it?

I’ve been working on a backend for a few clients of mine and thought I’ll add some form to enhance the function of the humble radio button.

So, where to begin? Well let’s take some HTML like this:

<label>
    <input type="radio" name="group" value="1" checked="checked" />
    <img src="1.jpg" />
</label>
<label>
    <input type="radio" name="group" value="2" />
    <img src="2.jpg" />
</label>
<label>
    <input type="radio" name="group" value="3" />
    <img src="3.jpg" />
</label>

So this gives us something like:




But this isn’t very magical, so we apply some simple CSS:

label
{
    display: block;
    float: left;
    margin: 5px;
    cursor: pointer;
}
label input
{
    display: none;
}
label img
{
    border: 4px solid #ffffff;
}
label input:checked + img
{
    border-color: #0080FF;
}

And this gives us something like:

And with this you get all the features of the radio button but it looks much nicer!

Where have comments gone?

Good question my old fruity. I'm now sticking any post discussions on Google+. Why? Well simply it's better. WordPress's comment system isn't very elegant and nor are ones like Disqus or Livefyre, so to save hassle I've just shipped them off to a social network, like a real boss.

Search

My social skills

Latest blog posts

  • Loading posts...

Subscribe in a reader

Latest tweets

  • Loading tweets...