Return to Snippet

Revision: 62256
at February 12, 2013 07:58 by COBOLdinosaur


Initial Code
function setposition()
{
    algset = new Array('left','right','center');
    sel=document.getElementById('theselect');
    sel.style.backgroundColor='blue';
    sel.style.textAlign='center';
    sel.style.color='orange';
    for (i=0;i<sel.options.length;i++)
    {
        if (i%2 ==0)
        {
            clr='white'; bclr='green';
        }
        else
        {
            clr='navy'; bclr='orange';
        }
        sel.options[i].style.color=clr;
        sel.options[i].style.backgroundColor=bclr;
        sel.options[i].style.textAlign=algset[i%3];
    }
}

Initial URL
http://coboldinosaur.com/pages/Styling_Options_for_Options.html

Initial Description
In modern browsers select options can now be style using most css properties. Of course, IE is still behind but it does support some styling as well.  There are a lot more options on the site.

Initial Title
Styling select options

Initial Tags
form, css, html5

Initial Language
CSS