修改select默认样式,兼容IE9

前面有篇文章已经提供了如何修改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();

});

效果如下图:

版权声明:本文为博主原创文章,未经博主允许不得转载。

时间: 2024-08-28 01:24:13

修改select默认样式,兼容IE9的相关文章

修改select 默认样式

删除select默认样式图标 appearance:none;-moz-appearance:none;-webkit-appearance:none; 修改样式图标 background: url('../image/getCustomer/arrow_select.png') no-repeat scroll right center #e9f5fe; 原文地址:https://www.cnblogs.com/gosimple/p/8376388.html

修改input默认样式

不说话,直接上代码 不需要图片,css解决 <!DOCTYPE html><html>    <head>        <meta charset="UTF-8">        <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" /&g

弹窗中修改select默认值遇到的问题

弹窗中修改select默认值无效 前提: 项目中遇到一个需求, 在一个弹窗中,有很多个select都是在打开弹窗的同时由js自动生成的(每次打开都自动重新生成一遍). 弹窗打开后,从每个select的下拉选中选中一个值.然后弹窗下面有个确定按钮. 点确定 按钮,将每个select选中的值保存起来. 下次再次打开弹窗时,每个自动生成的select中都默认值显示上次选中的值. 我的思路是: 1.在每次点 确定 按钮 时: 新建一个 js 对象jsonObj,每次点 确定后把 每个select的id(

【css】 如何修改select的样式

select { /*清除select默认样式*/ appearance:none; -moz-appearance:none; -webkit-appearance:none; -ms-appearance:none; border:1px solid #CCC; width:330px; height:44px; /*自定义箭头的样式,记得背景一定要加 白色或其他*/ background:url("../img/select.png") no-repeat scroll righ

ie下select默认样式修改

chrome下浏览: IE和FF下浏览: 使用select做下拉菜单,使用appearance:none;可以消除默认样式,但是要每个浏览器兼容到 .contactus2_con select{ -webkit-appearance: none; -moz-appearance: none; appearance:none; background:none; background:url("../images/select.jpg") right center no-repeat; w

纯css改变select默认样式

<!doctype html> <html lang="en"> <head> <meta charset="UTF-8" /> <title>Document</title> <style> select.sty1 { /*Chrome和Firefox里面的边框是不一样的,所以复写了一下*/ border: solid 1px #000; /*很关键:将默认的select选择框样式

去掉select 默认样式(ios)

<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title></title> <style type="text/css"> .sel { position: relative; width: 100px; } select { -webkit-appearance: none; /*兼容苹果手机*/ border: 1px

去除select默认样式

<!DOCTYPE html><html> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no"> <meta name="apple-mobile-web-app-

css取消input、select默认样式(手机端)

IOS端: border-color:transparent; andorid端: 仅仅使用上面的代码还不够,可以发现select框在某些浏览器(包括微信)内置浏览器下 还会有箭头以及高亮的线框,要除去这个可以使用 1 -webkit-appearance: none; 取消webkit默认的样式. 我们将input.select框设为透明的目的就是为了方便使用设计师制作的样式(即使差1.2个px没对齐也不会察觉) 注意:select的下拉框的样式跟具各个浏览器的不同都不会不同.这里就不研究了!