web前端关于<select>的技术问题讨论

 怎么改变<select>中的<option>的css样式?

出现以下问题是怎么回事?
(https://img-ask.csdn.net/upload/201609/30/1475201003_560257.png)
求解答

用层来模拟,如select2,系统默认显示的改变不了,改变下颜色或者背景色可以,就和普通控件那

 <style>select,option{color:red;background:#eee}</style>
<select><option>111</option><option>111</option></select>

最好用ul来做下拉,这样就可以自定义样式


测试:

默认显示

  • 1

  • 2




<br> $(&#39;.select&#39;).click(function(e){<br> $(&#39;ul&#39;,this).toggle();<br> e.stopPropagation();<br> var _this = this;</p> <pre><code> $(&#39;ul li&#39;,this).click(function(e){ e.stopPropagation(); $(&#39;.address&#39;,_this).hide(); $(&#39;span&#39;,_this).html($(this).html()); console.log($(&#39;.address&#39;,_this)); }) }); &lt;/script&gt; </code></pre>

可以用弹出层画一个select控件,css完全自定义就可以了。