Reputation: 1074
I have a select to choose a month. In the dropdown list I want to show just the name of the months (e.g. january, february). But in the box of the select (that shows the selected value) I want to show a FontAwesome icon (of a calendar) and then the name of the month selected.
That's how I want the select with the dropdown list closed look like
I got that but my dropdown list is like that
And I want it to be like that (without the calendar icon)
My code:
<select>
<option value="all"> All</option>
<option value="m01"> January</option>
<option value="m02"> February</option>
</select>
How can I do that?
Upvotes: 1
Views: 1732
Reputation: 361
Check this out.
http://jsfiddle.net/afshinprofe/qhCsJ/1/
It's exactly what you need to do. wrap your select in a container then give a background image with padding and no repeat, as you would do it for a text input.
<div class="selectParent">
<select>
<option value="1">Option 1</option>
<option value="2">Option 2</option>
</select>
</div>
and then the css would be
.selectParent{
width:80px;
overflow:hidden;
}
.selectParent select{
width:100px;
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
padding: 2px 2px 2px 20px;
border: none;
background: transparent url("http://cdn1.iconfinder.com/data/icons/cc_mono_icon_set/blacks/16x16/br_down.png") no-repeat left center;
}
Upvotes: 1