Marius Nel

A New Drop Down Select Design

by Marius Nel

2009/07/30

The drop-down select HTML element has become a staple in most online forms. It serves its particular purpose rather well - allowing a person to select one item from a list of choices.

The only problem is that the humble select element is the ugly duckling of the HTML form family. The font and background colour are the only elements you can style successfully across all browsers. Firefox, Chrome & Safari allow for more creativity, but as we all know, their big brother, Internet Explorer, has some serious issues with fashion. It prefers to enforce a very 1990's aesthetic, which in this case, is a very basic rectangular (no rounded corners or gradient background) construct.

Because of this backwards mentality, we (us Web building folks) were forced to design our forms with this limitation in mind. We cannot have a bunch of inputs with nice rounded corners and gradient backgrounds and then in the middle of it all a blue-bordered rectangle with an old-school down-arrow button glued to its side.

New select box.

Eventually my patience wore thin and I said to myself, enuff! (and thank goodness I knew just enough about Jquery's goodness to back this statement up). I started building one from scratch using an a-tag (with a background-image), an unordered list and some Jquery statements. The select element is still there, but I have hidden its ugly countenance. When you make your choice from the list, the value gets passed to the hidden select element ready for the submitting.

And that's it really... check out the demo.

Now ain't that sweet?
Notice that the second option delivers a vertical scroll-bar for long lists.

For those who know how to copy and paste, here is the code, CSS and HTML. You could also just download the zipped bundle.

Let the beautification begin!

P.S. If you are looking for a more fully-featured solution with all the bells and whistles, please use these clever people's solution. My solution is very basic and it certainly does not cover all the functionality of the original select element but it certainly looks better than the standard version.

About The Author

Comments

You make me so proud Mars... remember when we struggled to get this going for Vega.

Posted by Blaize on 2009/07/30

Thanks Blaize, if only IE wasn't such a retard amongst the browsers, we wouldn't need to rebuild these basic elements.

Posted by Mars on 2009/07/30

Radical dance party!! Thanks Marius.

Posted by Grant on 2009/07/30

If I click the dropdown so the list shows, and mouse-off to the right, the list doesn't go away.

Just a note- you might wanna fix.

Posted by b on 2009/08/05

Thank you "b" for the comment.

I wanted to re-create a standard HTML select element and therefore I built it to mimic some of its functionality.

If you inspect the behavior of a standard select element you would notice that the drop-down list stays visible when you mouse-off.

This is not a script to be used for a menu-item. Although if you really want to you can...

Your comment however did force me to fix the script so that the drop-down list will stay visible when you mouse-off. I added a "click" event that closes the drop-down list when you click outside the list. (This is how the standard select element functions)

Posted by Mars on 2009/08/06

Does it support acceptability?

Posted by Erez on 2009/08/06

Hi Erez,

Sure it supports "acceptability". I reckon its extremely acceptable...

Seriously though... I'm sure that you meant "accessibility", and the simple answer is no and in some cases it won't be usable at all.

If you need to meet accessibility requirements I would not recommend using this approach.

However I believe that this script can form the basis of a proper accessible select replacement. I am already working to incorporate it. So watch this space!

Posted by Mars on 2009/08/06

Wow!

A very interesting and well executed take on a selector. Great work!

If only all online forms would look this pretty...

Posted by Peter Lehto on 2009/08/06

I noticed that in IE8 the dropdown is displayed to the right. How to fix this?

Posted by Ira on 2009/10/18

Make a comment

To prevent GottaQuirk from becoming spam central, we block the use of certain words like porn, sex etc. We apologise for any inconvenience, but can't spend our lives deleting messages left by spammy friends.

Captcha