Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Icon in option - Bootstrap + Font-awsome

I am trying to embed an icon in an option from a select list. Using font-awesome icons, no icon is being displayed.

<select>
    <option><i class="icon-camera-retro"></i> Doesn't work in option!</option>
</select>

Can i use font-awesome to achieve what i need? Or do i have to scrap using font-awesome and do a manual CSS background for each option?

JSFiddle: http://jsfiddle.net/mmXh2/1/

like image 221
monokh Avatar asked May 13 '13 15:05

monokh


People also ask

How do you put an icon on an option tag?

To add icons in select option text we have to use the bootstrap-select plugin, which is a great plugin for customizing plain HTML select with some great customization options using bootstrap style. With this plugin, we can style the select element with only simple data attributes or initialize with Javascript.

What is fa fa caret down?

fa-caret-down Icon with Fixed Width So to display two icons with fixed width and height we can use fa-fw class. <i class='fas fa-caret-down fa-fw fa-3x'></i>Fixed Width<i class='fas fa-caret-down fa-3x'></i>Normal<br/> <i class='fas fa-home fa-fw fa-3x'></i>Fixed Width<i class='fas fa-home fa-3x'></i>Normal<br/>


2 Answers

You can use FontAwesome as a unicode font and insert your icons in a cross-platform way. You just need to look up the unicode value for each icon

<select style="font-family: 'FontAwesome', Helvetica;">
    <option>&#xf083; Now I show the pretty camera!</option>
</select>
like image 154
Sanojian Avatar answered Oct 11 '22 11:10

Sanojian


You can cheat a little bit and put the class on the option:

http://jsfiddle.net/mmXh2/2/

<option class="icon-camera-retro"> Doesn't work in option!</option>
like image 25
Billy Moat Avatar answered Oct 11 '22 11:10

Billy Moat