#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2002
    Posts
    10
    Rep Power
    0

    CSS: Highlight color in <select>


    How do I set the color of the highlighted (selected) option from a <select> field? For example, how would I change the color of the selected forum in the forum jump dropdown at the bottom of this page?

    Thanks.
  2. #2
  3. No Profile Picture
    Senior Citizen
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jan 2001
    Location
    leftcoast
    Posts
    2,019
    Rep Power
    16
    You wouldn't.
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2002
    Posts
    10
    Rep Power
    0
    Ahh, that would probably explain why I couldn't find out how.

    Thanks for the reply.
  6. #4
  7. Senior Member
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Jun 2000
    Location
    Enschede, The Netherlands
    Posts
    1,527
    Rep Power
    16
    You could

    Code:
    <style>
    option.opt1 {
    	background: #F1F1F1;
    }
    option.opt2 {
    	background: #0088FF;
    }
    </style>
    
    <select>
    <option value="" class=opt1>Test</option>
    <option value="" class=opt1>Test</option>
    <option value="" class=opt2 selected>Test</option>
    <option value="" class=opt1>Test</option>
    <option value="" class=opt1>Test</option>
    </select>
    There are 10 types of people in this world - those who understand binary and those who don't...

    PHP | MySQL | DevShed Forum Search | Google Search
  8. #5
  9. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2002
    Posts
    10
    Rep Power
    0
    Mirax,

    That isn't quite what I want to do. I want to set the color of the item the mouse is over. Currently it defaults to whatever "Selected Items" in the Display Properties is set to.
  10. #6
  11. Senior Member
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Jun 2000
    Location
    Enschede, The Netherlands
    Posts
    1,527
    Rep Power
    16
    okay, something with option onMouseOver="highlight()" and a javascript function which changes the style of the option should do it then?
    There are 10 types of people in this world - those who understand binary and those who don't...

    PHP | MySQL | DevShed Forum Search | Google Search
  12. #7
  13. No Profile Picture
    CF sMod
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Location
    Maine, USA (a.k.a. Boonies)
    Posts
    242
    Rep Power
    15
    IE does not fire any events on <option/> elements.

    In Gecko, with XBL form bindings enabled, this is possible. But they are disabled by default.
    Jason Contact Me
    Super moderator @ CodingForums
  14. #8
  15. Senior Member
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Jun 2000
    Location
    Enschede, The Netherlands
    Posts
    1,527
    Rep Power
    16
    forget my JavaScript comment, it's nonsense

    The only thing I can think of would be some css code, but I can't find it anywhere One would expect it's possible to change the color like it is possible to change the scrollbar color (also system dependant)
    There are 10 types of people in this world - those who understand binary and those who don't...

    PHP | MySQL | DevShed Forum Search | Google Search
  16. #9
  17. No Profile Picture
    Senior Citizen
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jan 2001
    Location
    leftcoast
    Posts
    2,019
    Rep Power
    16
    You wouldn't.

IMN logo majestic logo threadwatch logo seochat tools logo