Styling a <select> menu - html

I have a select menu like this:
<select name="mySelect">
<option value="250" selected="selected">250</option>
<option value="500">500</option>
<option value="1000">1000</option>
<option value="1500">1500</option>
</select>
It comes out looking different depending on OS and I would like it to have a different background. The problem is when I use a standard css background the arrow on the right of the select element remains visible.
select {
background: url(../images/bg_select.png);
}
I would also like to have different background colours when the select list has been opened. The default is often blue and white.
Edit: Looks like I'll have to use javascript. Are there any jQuery plugins to do this?

You may want to look at this: Cut & Paste DHTML Select menu. It uses Javascript to replace the select menu with custom HTML.

all a listener to the select and use jquery to trigger the class
add/remove classes should work fine

Related

How to create a selectable list in Materialize CSS

I want to create a select that looks like a collection in Materialize CSS.
I know that in order to do something like that on plain HTML I need to use the size attribute.
<select id="someSelect" size="8">
<option value="3">Blabla</option>
<option value="4">Bla</option>
...
</select>
Howhever, when I add it, it doesn't change anything, and the select is still a dropdown and not a list.
How could I create a selectable list (only one selection at a time) in Materialize CSS?
EDIT:
bahman parsamanesh mentioned in his comment the usage of <div class="collection"> and <a> inside it, which is exactly I was looking for, but how could I handle it's onChange?

How can I change color of a select option with CSS on hover?

<select style="width:245px;">
<option value="rseleccionar">Seleccione..</option>
<option value="bs">Bienes Separados</option>
<option value="bm">Bienes Mancomunados</option>
</select>
I want to change the blue color of default for another.
Styling select and option tag is very limited.
This is because the way they are displayed may change according to the browser/the OS. Think about what happens when you click a select tag on your phone. You don't get a dropdown list as expected on a desktop browser. So you couldnt style something universal as it doesn't natively display the save everywhere.
Styling possibilities are: mainly on the select tag but very restricted on the option. You could for example disable the native style of the select box:
select {
appearance: none;
/* may need vendors prefixes. */
}
Other solution is: jQuery plugins that simulate select box using other HTML tags:
https://jqueryui.com/selectmenu/
https://github.com/marcj/jquery-selectBox
And all that Google may return you with keywords "jQuery select box" :)
Option elements are rendered by the OS, not HTML. You cannot change the style for these elements.
Try this, hope it'll work
<select class="hover_color" style="width:245px;">
<option value="rseleccionar">Seleccione..</option>
<option value="bs">Bienes Separados</option>
<option value="bm">Bienes Mancomunados</option>
</select>
.hover_color:hover { background-color: red; border:1px solid red }

How to add rtl support to angular chosen

I'm using angular with chosen ( source) , and i'm trying to add rtl support , here is my Demo . i've read this but it's not working .
The problem is when body has dir="rtl" attribute after click on select list , page get horizantal scroll .
<select class="chzn-rtl" chosen disable-search="false"
no-results-text="'Tough luck'"
ng-model="bar">
<option>Hi</option>
<option>This is fun</option>
<option>I like Chosen so much</option>
<option>I also like bunny rabbits</option>
<option value=""></option>
</select>
Demo
This is happening because chosen dropdown never getting close &
On start up it goes most left of the end where scroll bar end.
CSS
.chosen-container{
.position: fixed;
z-index: 99;
}
Adding inside your style will fix this problem. I haven't find any good fix for it. This is some what hacky way but this work around I found.
Working Plunkr
Thanks.

Dropdown Menu Options are Image (not text)

I want to ask about html dropdown menu. As we know, that option tag in html only support text. However, I need to create a drowp down menu that show list of image. I've searched for it. And I found several ways, including using css or jquery. However, that's not what I want. Here is, what I want to create:
<option value = blablabla><img src = "img/blbalba.txt"></option>
The code above is not working. Is there any sugestion to display dropdown menu like that?
Thank you for your help.
As You can't do that in plain HTML, but you can do it with JQuery.
Right now You can do like this
<select>
<option value="img1" style="background-image:url(images/img1.png);">image 1</option>
<option value="img2" style="background-image:url(images/img2.png);">image 2</option>
<option value="img3" style="background-image:url(images/img3.png);">image 3</option>
<option value="img4" style="background-image:url(images/img4.png);">image 4 </option>
</select>
Browsers will only render text inside a select tag, so, if you wan to use a selector that shows images instead of text, you cannot use a select you'll need to build your own selectable object.
That could be quite difficult to do. You can use different premade solutions that people on your situation developed before or try to reinvent the wheel.
Check this :)
A free light weight jQuery plugin that allows you to create a custom drop down with images and description.
What is so cool about this plugin!
Adds images and description to otherwise boring drop downs.
Allows JSON to populate the drop down options.
Converts your HTML select element to ddSlick.
Uses Minimum css and no external stylesheets to download.
Supports callback functions on selection.
Works as good even without images or description!
http://designwithpc.com/Plugins/ddSlick#demo

How to put image into the select menu

How can I put image next to the text in the select menu.
For example this is not working:
<select style="background-color:black; width:150px;color:white;">
<option style="background-image:url(images/english.png);">English</option>
</select>
This is not working. I want to have a little flag first and then name of the language.
The select element does not support that type of thing. It's meant to be a native control that's consistent wherever it's used. You can, however, whip up your own custom drop-down style menu.
Here's one I did (under the graph).Also, here's a jquery plugin that might make it easier for you.
Good luck!