【发布时间】:2014-10-15 10:26:36
【问题描述】:
我了解到设置选择框样式的最佳方法是将其包装在一个带样式的 div 中,所以我做到了;我的 div 有一类选择样式。我希望选择框的背景颜色在焦点上改变,但我一生都无法弄清楚如何保留下拉插入符号(这是背景图像)。
这是我的代码:
<!doctype html>
<html>
<head>
<title>Select Box Styling</title>
<meta charset="utf-8" />
<style type="text/css">
body {
background-color: #FFF;
font-family: Helvetica, Arial, sans-serif;
padding: 30px;
margin: 0;
}
.select-style {
width: 240px;
height: 34px;
overflow: hidden;
background: transparent url('dropdown-arrow4.gif') no-repeat right;
border: 1px solid #8DC63F;
border-radius: 4px;
}
.select-style select {
background-color: transparent;
width: 268px;
padding: 5px;
font-size: 14px;
line-height: 1;
border: 0;
border-radius: 0;
height: 34px;
-webkit-appearance: none;
font-family: Helvetica, Arial, sans-serif;
color: #222;
}
.select-style select:focus,
.select-style select:active {
outline: none;
background-color: #ECF7CB;
}
</style>
</head>
<body>
<div class="select-style">
<select>
<option>The first option</option>
<option>The second option</option>
<option>The third option</option>
</select>
</div>
</body>
</html>
任何帮助将不胜感激!
【问题讨论】: