改动select默认样式,兼容IE9
2017-08-04 10:28
197 查看
前面有篇文章已经提供了怎样改动select标签的默认样式,可是仅仅能兼容到ie10,要兼容ie9仅仅能模拟一个类似的
html结构:
<div class="select_diy">
<select>
<option value="产品咨询1">产品咨询1</option>
<option value="产品咨询2">产品咨询2</option>
<option value="产品咨询3">产品咨询3</option>
<option value="产品咨询4">产品咨询4</option>
</select>
<div class="select_diy_select"></div>
</div>
css样式:
.contactus2_con select{
-webkit-appearance: none;
-moz-appearance: none;
appearance:none;
background:none;
background:url("../images/select.jpg") right center no-repeat;
background:white\9\0;
width:490px;
border:1px solid #d9d9d9;
height:30px;
cursor:pointer;
}
.contactus2_con select::-ms-expand{
color: #fff;
font-size:20px;
padding:5px 9px;
background: #0054a7;
}
.select_diy{
position:relative;
width:490px;
}
.select_diy_select{
position:absolute;
top:0px;
right:0px;
width:37px;
height:30px;
background:url("../images/select.jpg") center center;
border-radius:0px 4px 4px 0px;
cursor:pointer;
}
js:
$(".select_diy_select").click(function(){
var $target = $(this).siblings("select");
var $clone = $target.clone();
$clone.val($target.val()).css({
position: 'absolute',
'z-index': 999,
width:$target.width(),
left: $target.offset().left,
top: $target.offset().top + $target.height()
}).attr('size', $clone.find('option').length).change(function() {
$target.val($clone.val());
}).on('click blur',function() {
$(this).remove();
});
$('body').append($clone);
$clone.focus();
});
效果例如以下图:
html结构:
<div class="select_diy">
<select>
<option value="产品咨询1">产品咨询1</option>
<option value="产品咨询2">产品咨询2</option>
<option value="产品咨询3">产品咨询3</option>
<option value="产品咨询4">产品咨询4</option>
</select>
<div class="select_diy_select"></div>
</div>
css样式:
.contactus2_con select{
-webkit-appearance: none;
-moz-appearance: none;
appearance:none;
background:none;
background:url("../images/select.jpg") right center no-repeat;
background:white\9\0;
width:490px;
border:1px solid #d9d9d9;
height:30px;
cursor:pointer;
}
.contactus2_con select::-ms-expand{
color: #fff;
font-size:20px;
padding:5px 9px;
background: #0054a7;
}
.select_diy{
position:relative;
width:490px;
}
.select_diy_select{
position:absolute;
top:0px;
right:0px;
width:37px;
height:30px;
background:url("../images/select.jpg") center center;
border-radius:0px 4px 4px 0px;
cursor:pointer;
}
js:
$(".select_diy_select").click(function(){
var $target = $(this).siblings("select");
var $clone = $target.clone();
$clone.val($target.val()).css({
position: 'absolute',
'z-index': 999,
width:$target.width(),
left: $target.offset().left,
top: $target.offset().top + $target.height()
}).attr('size', $clone.find('option').length).change(function() {
$target.val($clone.val());
}).on('click blur',function() {
$(this).remove();
});
$('body').append($clone);
$clone.focus();
});
效果例如以下图:
相关文章推荐
- 修改select默认样式,兼容IE9
- 去除select下拉框默认样式以及一些兼容问题
- select默认样式美化代码兼容移动端和pc端
- [原创] select控件样式(兼容IE6、IE7、Firefox 2.0)
- 用纯css改变下拉列表select框的默认样式(不兼容IE10以下)
- 修改select的默认样式
- select默认下拉箭头改变、option样式清除
- CSS3 重置iphone浏览器按钮input,select等表单元素的默认样式
- select控件样式(兼容IE6、IE7、Firefox 2.0)
- input、select、textarea兼容不同浏览器样式统一
- 去除select的默认样式
- select默认下拉箭头改变、option样式清除
- SELECT样式,兼容IE6
- CSS —— 兼容各个浏览器的select的样式
- 用CSS3写的一个简单分页样式(兼容ie9及以上)
- 【CSS修改下拉选框select的默认样式】
- css更改select样式关于ie的兼容
- 下拉菜单select样式设置(兼容IE6/IE7/IE8/火狐)
- select去除默认样式,去掉边框,选中时去除虚线
- css取消input、select默认样式(手机端)