CSS怎么去掉select的下拉箭头样式
2个回答
展开全部
select一直是html里的怪胎,很多属性不受css控制的,所以才会出现很多div+css的下拉插件,如果项目需要 非要用元素select的话,可以在select上做一个小小的遮罩,通过定位到下拉箭头,挡住后面的箭头就行了。
纯手打,望采纳!
纯手打,望采纳!
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2017-08-10
展开全部
css是无法去掉默认select的下拉箭头的,除非自己用div+js+css实现自定义select控件。
1、定义html中的select标签
<form>
<a class="btn-select" id="btn_select">
<span class="cur-select">请选择</span>
<select>
<option>选项一</option>
<option>选项二</option>
<option>选项三</option>
<option>选项四</option>
<option>选项五</option>
</select>
</a>
</form>
2、定义css样式:
* {
margin: 0;
padding: 0;
}
body {
padding: 50px 50px;
}
.btn-select {
position: relative;
display: inline-block;
width: 150px;
height: 25px;
background-color: #f80;
font: 14px/20px "Microsoft YaHei";
color: #fff;
}
.btn-select .cur-select {
position: absolute;
display: block;
width: 150px;
height: 25px;
line-height: 25px;
background: #f80 url(ico.png) no-repeat 125px center;
text-indent: 10px;
}
.btn-select:hover .cur-select {
background-color: #f90;
}
.btn-select select {
position: absolute;
top: 0;
left: 0;
width: 150px;
height: 25px;
opacity: 0;
filter: alpha(opacity: 0;);
font: 14px/20px "Microsoft YaHei";
color: #f80;
}
.btn-select select option {
text-indent: 10px;
}
.btn-select select option:hover {
background-color: #f80;
color: #fff;
}
3、定义点击事件JS:
var $$ = function (id) {
return document.getElementById(id);
}
window.onload = function () {
var btnSelect = $$("btn_select");
var curSelect = btnSelect.getElementsByTagName("span")[0];
var oSelect = btnSelect.getElementsByTagName("select")[0];
var aOption = btnSelect.getElementsByTagName("option");
oSelect.onchange = function () {
var text=oSelect.options[oSelect.selectedIndex].text;
curSelect.innerHTML = text;
}
}
4、最终效果:
1、定义html中的select标签
<form>
<a class="btn-select" id="btn_select">
<span class="cur-select">请选择</span>
<select>
<option>选项一</option>
<option>选项二</option>
<option>选项三</option>
<option>选项四</option>
<option>选项五</option>
</select>
</a>
</form>
2、定义css样式:
* {
margin: 0;
padding: 0;
}
body {
padding: 50px 50px;
}
.btn-select {
position: relative;
display: inline-block;
width: 150px;
height: 25px;
background-color: #f80;
font: 14px/20px "Microsoft YaHei";
color: #fff;
}
.btn-select .cur-select {
position: absolute;
display: block;
width: 150px;
height: 25px;
line-height: 25px;
background: #f80 url(ico.png) no-repeat 125px center;
text-indent: 10px;
}
.btn-select:hover .cur-select {
background-color: #f90;
}
.btn-select select {
position: absolute;
top: 0;
left: 0;
width: 150px;
height: 25px;
opacity: 0;
filter: alpha(opacity: 0;);
font: 14px/20px "Microsoft YaHei";
color: #f80;
}
.btn-select select option {
text-indent: 10px;
}
.btn-select select option:hover {
background-color: #f80;
color: #fff;
}
3、定义点击事件JS:
var $$ = function (id) {
return document.getElementById(id);
}
window.onload = function () {
var btnSelect = $$("btn_select");
var curSelect = btnSelect.getElementsByTagName("span")[0];
var oSelect = btnSelect.getElementsByTagName("select")[0];
var aOption = btnSelect.getElementsByTagName("option");
oSelect.onchange = function () {
var text=oSelect.options[oSelect.selectedIndex].text;
curSelect.innerHTML = text;
}
}
4、最终效果:
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询