Solved

How to change background color in a select list?

Posted on 2010-09-21
8
557 Views
Last Modified: 2012-05-10
Is it possible to change the default background color from a select list in HTML, when trying to hover over the selection?
0
Comment
Question by:paulinewin
  • 3
  • 2
8 Comments
 
LVL 30

Expert Comment

by:Steggs
ID: 33731160
Hello,

I just did a quick test in my browsers.

<style>
select:hover {background-color:red}
option:hover {background-color:orange}
</style>

<select><option value="1">1</option></select>

Firefox4 beta - red on hover
Chrome - red on hover
safari - red on hover
opera - red on hover
IE9 beta - no change on hover


Hope this helps
0
 

Author Comment

by:paulinewin
ID: 33731864
Thank you so much Steggs.

What I was hoping to accomplish is a bit different.  In a list such as the one below, when the user goes through all the options, the background color of each item change from white to blue to highlight the option.  I was hoping to change the blue to another color, but just one item at a time as the mouse hover over each item.  Is that possible to do?  If yes, is it fairly simple to accomplish?
<select>
      <option>item 1</option>
      <option selected="selected">item 2</option>
      <option>item 3</option>
      <option>item 4</option>
      <option>item 5</option>
      <option>item 6</option>
      <option>item 7</option>
      <option>item 8</option>
      <option>item 9</option>
</select>

Thank you!
0
 
LVL 14

Accepted Solution

by:
Dushyant Sharma earned 200 total points
ID: 33731905
I dont' think you can do this by using css. the selected option will always have default properties (blue background and white font color).

perhaps you can create a javascript based dropdown list and style it any way you like.
0
Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

 
LVL 30

Assisted Solution

by:Steggs
Steggs earned 50 total points
ID: 33731946
yeh this is not possible in css. You may want to look for a js solution, maybe something like this http://www.devirtuoso.com/2009/08/styling-drop-down-boxes-with-jquery/
0
 

Author Closing Comment

by:paulinewin
ID: 33732274
Thank you Steggs!  The only problem I have with the js solution is I don't know how to expand the width of the container.  It's not in the css file.
0
 
LVL 30

Expert Comment

by:Steggs
ID: 33764629
what is going on here? I don't see any authorisation from paulinewin to change the accepted answer.

Also, you don't seem to have factored in the first answer where I tested if it was possible with css at all.
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
how can i make the array into an object? 4 33
Why doesn't Google directions work? 6 47
Is there a way to use PhantomJS on a shared server? 4 17
div to fit another div 8 23
CSS is a visual language used to classify objects and define rules about how they should be displayed. CSS skills aren’t restricted to developers anymore, there is a big benefit to having a basic understanding of the language, regardless of your occ…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
In this tutorial viewers will learn how add a full-size background image to a webpage using CSS3. Create a new HTML document with an internal stylesheet.: In CSS, define the html element to have a background image. Use a high resolution image.: In t…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question