c# - Change background colour of dropdownlist selected item in ASP.NET with CSS -
i change background colour of selected item in dropdownlists, listboxes, , textboxes. possible css?
thanks
update
just tried css:
::-moz-selection { background-color:#8cca1e; color:black; }
works great selected text not hover colours or selected item colours on dropdownlists or listboxes.
you can set background colors .aspx page specifying either cssclass, or backcolor property.. looks like:
<asp:listbox cssclass="mylistbox" backcolor="#e0e0e0"></asp:listbox>
setting selected item little trickier... don't believe there attribute directly. can set in javascript, or jquery, like:
// never mind, won't work <script type="text/javascript"> $(document).ready(function() { $('#mylistbox').click(function() { $("#mylistbox option:selected").css("background-color", "#e0e0e0"); }); }); </script>
i'll test make sure works... if need straight javascript solution, i'll see can come with. if you're not using jquery, , want fine-grained control on controls, time learn : )
thanks justin corrections script!
edit
hover easy... add style:
select > option:hover { background-color: #ffffd0; }
that set background color on listbox item hover on over page. jquery can used set click function on listboxes, not #mylistbox... give me couple of minutes, i'll add code
update
after extensive research, exhausting every resource had or can put hands on, best answer come is: setting selected color can't done.
not jquery code came work. selected color set os, , can't overridden.
sorry, best can :hover pseudo-selector
: (
.
Comments
Post a Comment