【发布时间】:2014-04-22 09:54:24
【问题描述】:
我的代码在除IE 之外的所有浏览器中都运行良好。我为选择设置了样式,但无法删除IE 中的默认箭头。
简单代码:HTML
<form>
<label for="selectitem">Food Favorites</label>
<select id="selectitem">
<option>Choose...</option>
<option value="italian">Italian</option>
<option value="japanese">Japanese</option>
<option value="mexican">Mexican</option>
<option value="vietnamese">Vietnamese</option>
</select>
</form>
CSS 代码:
form {
position: relative;
top: 50px;
}
form * {
-webkit-appearance: none;
-moz-appearance: none;
background: transparent;
behavior: url(PIE.htc);
}
select, option {
border: none;
background: none;
-webkit-border-radius: 0;
-moz-border-radius: 0;
border-radius: 0;
padding: 0;
margin: 0;
}
body {
background: #666;
}
form {
position: relative;
width: 340px;
margin: 0 auto;
font-weight: bold;
color: #DDD;
}
select {
background: #555;
border-radius: 4px;
width: 240px;
height: 35px;
background: url('select.png') no-repeat;
color: #DDD;
padding: 8px;
outline: solid transparent;
-webkit-appearance: none;
-moz-appearance: none;
text-indent: 1px;
text-overflow: '';
}
select:focus {
background: url('select.png') no-repeat 0 -35px;
}
option {
background: #666;
color: #DDD;
padding: 5px;
text-align: center;
}
我设法用
删除了 Firefox 中的箭头webkit-appearance: none;
-moz-appearance: none;
text-indent: 1px;
text-overflow: '';
供选择的背景图片:http://i.imgur.com/PSolPt7.png
【问题讨论】:
-
行为:用于旧版 IE 支持的 url(PIE.htc)
-
我个人的看法是你不应该不设置表单元素的样式。人们已经习惯了他们看起来像他们的样子,而改变这会让他们感到困惑。
-
@ Niet the Dark Absol 你说的没错,但我的一些雇主要求为表单定制设计