[英]How to use correctly fontawesome in select
I'm trying to show the fontawesome icons in a select, but in the drop-down list the icons are not previewed well我试图在选择中显示字体很棒的图标,但在下拉列表中图标预览效果不佳
.FontAwesomeSelect { font-family: Font Awesome\\ 5 Free; font-size: 18px; }
<link href="https://use.fontawesome.com/releases/v5.0.6/css/all.css" rel="stylesheet"/> <select name="sample" id="sample" class="FontAwesomeSelect"> <option value="">----</option> <option value="fa fa-address-card"></option> <option value="fa fa-bell"></option> <option value="fa fa-bookmark"></option> <option value="fa fa-building"></option> </select>
You don't need the FontAwesomeSelect
class.您不需要
FontAwesomeSelect
类。 Instead, use the default fa
class.相反,使用默认的
fa
类。
<select name="sample" id="sample" class="fa">
<option value="">----</option>
<option value="fa fa-address-card"></option>
<option value="fa fa-bell"></option>
<option value="fa fa-bookmark"></option>
<option value="fa fa-building"></option>
</select>
Fiddle : https://jsfiddle.net/JonathanParentLevesque/uwe8azo7/4/小提琴: https : //jsfiddle.net/JonathanParentLevesque/uwe8azo7/4/
Notice well what contains this class:请注意包含此类的内容:
If it's still not working, try this:如果它仍然无法正常工作,请尝试以下操作:
.fa option {
font-weight: 900;
}
using the previous example i did this使用前面的例子我做了这个
<select name="sample" id="sample" class="fa">
<option value="">----</option>
<option value="fa fa-address-card"></option>
<option value="fa fa-bell"></option>
<option value="fa fa-bookmark"></option>
<option value="fa fa-building"></option>
And add this custom css并添加这个自定义css
select.form-control.fa option{ font-weight: 900; }
working with font awesome 5.6.3使用字体真棒 5.6.3
<style>
.fa option {
font-weight: 900;
}
</style>
Then the options can look like this:然后选项看起来像这样:
<option class="fa" value="select_value"> Name Of Select</option>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.