【问题标题】:Is it possible to use Font Awesome icon instead to select default drop down sign是否可以使用 Font Awesome 图标来选择默认的下拉符号
【发布时间】:2014-07-13 07:27:39
【问题描述】:

我想使用字体真棒“fa-chevron-down”图标而不是 html 选择框默认样式。请看附图。

【问题讨论】:

标签: html css fonts font-awesome


【解决方案1】:

您可以使用伪类来做到这一点。我按照here 的步骤进行了修改,删除了转换,使用 FontAwesome 作为我的字体,图标的 UTF-8 作为内容as instructed here

select {
padding:4px;
margin: 0;
background: #fff;
color:#888;
border:none;
outline:none;
display: inline-block;
-webkit-appearance:none;
-moz-appearance:none;
appearance:none;
cursor:pointer;
width: 150px;
-webkit-border-radius: 0px;
-moz-border-radius: 0px;
border-radius: 0px;
}

/* Targetting Webkit browsers only. FF will show the dropdown arrow with so much padding. */
@media screen and (-webkit-min-device-pixel-ratio:0) {
select {padding-right:18px}
}

label {position:relative}
label:after {
content:"\f078";   
font-family: "FontAwesome";
font-size: 11px;
color:#aaa;
right:8px; top:4px;
padding:0 0 2px;
position:absolute;
pointer-events:none;
}
label:before {
content:'';
right:4px; top:0px;
width:23px; height:18px;
background:#fff;
position:absolute;
pointer-events:none;
display:block;
}

Here's a codepen in action.

【讨论】:

  • 示例将下拉图标放在我的标签上,而不是在我的选择框上
猜你喜欢
  • 1970-01-01
  • 2023-02-08
  • 1970-01-01
  • 2014-11-01
  • 1970-01-01
  • 2020-05-29
  • 2018-06-07
  • 1970-01-01
  • 2022-01-10
相关资源
最近更新 更多