我一直在努力尝试将一个字体很棒的图标放入选择选项(下拉菜单)。我尝试过在此网站上发布的解决方案here。但是,这会将字体很棒的图标放在标签旁边,而不是在选择选项框中。
我也尝试将unicode直接放入html选项标签中......但是,一旦点击该向下箭头,它就会变成一个问号。 (另外,我不能在这个项目中使用bootstrap)
请帮忙!
HTML:
<div class="modal-form stack col75">
<label for="game">Game:</label>
<select class="form-control easy-drop-down" id="modal-game-options">
<option selected disabled>Please Select a Show</option>
<option>2</option>
<option>3</option>
<option>4</option>
</select>
</div>
CSS:
select {
border-radius: 0;
-webkit-border-radius: 0px;
-moz-border-radius: 0px;
-o-border-radius: 0px;
border-radius: 0px;
-webkit-appearance: none;
background-color: white;
padding-left: 20px;
content: "";
}
以下是一些快照
电流: without-arrow
目标: with-arrow
答案 0 :(得分:1)
链接实际上做错了什么:
1-标签在选择之前不结束,之后结束。
2-标签用于生成字体真棒图标,内容通过后子选择。
<强> HTML 强>
<div class="modal-form stack col75">
<label for="game">Game:
<select class="form-control easy-drop-down" id="modal-game-options">
<option selected disabled>Please Select a Show</option>
<option>2</option>
<option>3</option>
<option>4</option>
</select>
</label>
</div>
<强> CSS 强>
select {
border-radius: 0;
-webkit-border-radius: 0px;
-moz-border-radius: 0px;
-o-border-radius: 0px;
border-radius: 0px;
-webkit-appearance: none;
background-color: white;
width: 175px;
}
@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:3px;
padding:0 0 1px;
position:absolute;
pointer-events:none;
}
label:before {
content:'';
right:4px; top:0px;
width:20px; height:16px;
background:#fff;
position:absolute;
pointer-events:none;
display:block;
}
答案 1 :(得分:0)
我通过删除&#34;选中的已停用&#34;来尝试您的代码从第一个选项tag.it对我来说很完美。
<div class="modal-form stack col75">
<label for="game">Game:</label>
<select class="form-control easy-drop-down" id="modal-game-options">
<option >Please Select a Show</option>
<option>2</option>
<option>3</option>
<option>4</option>
</select>
</div>
答案 2 :(得分:0)
这是我的代码。你应该试试这个。
HTML代码
<style>
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;
}
</style>
CSS脚本
union
{
unsigned long longvalue;
signed short shortvalues[2];
}
value;
答案 3 :(得分:0)
我对@ DarkHyudrA'sanswer进行了一些更改..
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css">
<style>
select {
border-radius: 0;
-webkit-border-radius: 0px;
-moz-border-radius: 0px;
-o-border-radius: 0px;
border-radius: 0px;
-webkit-appearance: none;
background-color: white; padding:8px 10px; border-radius:2px; border:#ADD8E6 solid 1px;
}
@media screen and (-webkit-min-device-pixel-ratio:0) {
select {padding-right:35px}
}
label {position:relative}
label:after {
content:"\f078";
font-family: "FontAwesome";
font-size: 10px;
color:#aaa;
right:10px; top:3px;
padding:0 0 1px;
position:absolute;
pointer-events:none;
}
label:before {
content:'';
right:4px; top:0px;
width:20px; height:16px;
background:#fff;
position:absolute;
pointer-events:none;
display:block;
}
</style>
<div class="modal-form stack col75">
<div class="modal-form stack col75">
<label for="game">Game:
<select class="form-control easy-drop-down" id="modal-game-options">
<option selected disabled>Please Select a Show</option>
<option>2</option>
<option>3</option>
<option>4</option>
</select>
</label>
</div>
</div>
这里是小提琴