<select>在chrome浏览器下背景透明问题
在上篇文章《只用CSS美化选择框》运用了背景透明的技巧来美化选择框,但在chrome浏览器下遇到了跟ie、ff不一样的透明效果,下面重现一下:
在一个大的div(背景红色)内放置一个select元素(背景透明)。在线查看(可在不同浏览器中查看效果)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>chrome浏览器下select元素透明问题</title>
</head>
<body>
<div style="width: 200px; height: 200px; background: red">
<select style="background: transparent;"><!--微信浏览器是可以的-->
<option>Here is the first option</option>
<option>The second option</option>
</select>
</div>
</body>
</html>
我们期望的效果如图:


但chrome浏览器却是这样子的

问题不言而喻了,chrome居然没有按照bacground:tansparent的指令行事,好吧,我认为它是另类,给它一个偏方-webkit-appearance: none;(取消webkit默认的样式)试试!修改后代码在线效果 查看

确实透明了,但是好像默认的下拉小箭头也透明了(严格来说应该是消失了),stackoverflow上也有相关问题
http://stackoverflow.com/questions/4142619/how-to-make-select-element-be-transparent-in-chrome
总结:webkit内核浏览器(chrome、safari)有自己的默认样式,针对webkit核心的浏览器使用-webkit-appearance: none让select背景透明;这好像不完美,下拉箭头没了,我也没找到完美的方法——既能背景透明又能不失去那个下拉箭头。推荐《只用CSS美化选择框》来实现自定义的select框吧!
有完美的方法,请告知一声,谢谢!
原文地址:http://www.cnblogs.com/shishm/archive/2012/03/02/2377354.html
<select>在chrome浏览器下背景透明问题的更多相关文章
- 一个解决chrome浏览器下input标签当autocomplete的时候背景变黄色同时input背景图片消失方案
最近在改一个bug即如标题所讲的一样,chrome浏览器下当input标签开启autocomplete的时候input的背景颜色变黄同时在input的背景图片也被覆盖了.为此百度了好久发现网上说的使用 ...
- Chrome浏览器下自动填充的输入框背景
记录下从张鑫旭老师的微博中看到关于input输入框的属性 1.autocomplete="off" autocomplete 属性规定输入字段是否应该启用自动完成功能 自动完成允许 ...
- 取消chrome浏览器下input和textarea的默认样式
最近一个细节引起了我的注意,chrome浏览器下的input和textarea在聚焦的时候都有一个黄色的边框,而且textarea还可以任意拖动放大,这是不能容忍的,影响美观不说,有时候拖动texta ...
- 取消chrome浏览器下input和textarea的默认样式;html5默认input内容清除“×”按钮去除办法
取消chrome浏览器下input和textarea的默认样式: outline:none;/*清空chrome中input的外边框*/ html5默认input内容清除“×”按钮去除办法: inpu ...
- chrome浏览器下页面顶部出现一条空白解决
最近遇到页面在chrome浏览器下,顶部会出现一条空白的问题.后来知道是bom头的问题. 1.什么是bom头? BOM签名的意思就是告诉编辑器当前文件采用何种编码,方便编辑器识别,但是BOM虽然在编辑 ...
- chrome浏览器的跨域设置 Google Chrome浏览器下开启禁用缓存和js跨域限制--disable-web-security
chrome用户默认路径 Win7:C:\Users\[用户名]\AppData\Local\Google\Chrome\User Data\XP:C:\Documents and Settings\ ...
- chrome浏览器下的xdebug helper使用方法
chrome浏览器下的xdebug helper使用方法 自从安装了xdebug后,发现每次调试都需要从eclipse中先从头启动,然后一步步走到你要调试的页面,而不是说想什么时候调试就什么时 ...
- button 在chrome浏览器下被点击时会出现一个橙色的边框
问题描述: button在chrome浏览器下被点击时会出现一个橙色的边框 在button上添加 :focus{outline:none;}也无法解决. 解决办法: 在button上添加 :focus ...
- Chrome浏览器下调试SASS
网上说的方案各有各的说法,尝试多个才找到有效方案,为避免后来者麻烦,现在讲讲如何调试 笔者ruby版本为3.4.19,因为sass文件的编译是需要ruby环境的,使用sass前需要先安装! 第一步(核 ...
随机推荐
- ID
id 编辑 身份标识号.账号.唯一编码.专属号码.工业设计.国家简称.法律词汇.通用账户.译码器.软件公司等,各类专有词汇缩写. 身份证,身份识别,是一种身份证明. 中文名 身份证,帐号,工业设计,通 ...
- BSGS算法_Baby steps giant steps算法(无扩展)详解
Baby Steps-Varsity Giant Step-Astronauts(May'n・椎名慶治) 阅读时可以听听这两首歌,加深对这个算法的理解.(Baby steps少女时代翻唱过,这个原唱反 ...
- iOS上传应用过程中出现的错误"images contain alpha channels or transparencies"以及解决方案
如何取消图片透明度 本文永久地址为 http://www.cnblogs.com/ChenYilong/p/3989954.html,转载请注明出处. 当你试图通过<预览>进行" ...
- luarocks install with lua5.1 and luajit to install lapis
# in luarocks source directory...git clone https://github.com/archoncap/luarockscd luarocks ./config ...
- neutron 中 flat vlan gre vxlan的区别
In a flat network, everyone shares the same network segment. For example, say 2 tenants are sharing ...
- 应用 JD-Eclipse 插件实现 RFT 中 .class 文件的反向编译
概述 反编译是一个将目标代码转换成源代码的过程.而目标代码是一种用语言表示的代码 , 这种语言能通过实机或虚拟机直接执行.文本所要介绍的 JD-Eclipse 是一款反编译的开源软件,它是应用于 Ec ...
- Intersection of Two Arrays | & ||
Intersection of Two Arrays Given two arrays, write a function to compute their intersection. Example ...
- Python OpenSource Project
http://www.oschina.net/project/lang/25/python
- JSON: property "xxx" has no getter method in class "..."
Exception in thread "main" net.sf.json.JSONException: java.lang.NoSuchMethodException: Pro ...
- local variable 'xxx' referenced before assignment
这个问题很囧,在外面定义了一个变量 xxx ,然后在python的一个函数或类里面引用这个变量,并改变它的值,结果报错local variable 'xxx' referenced before as ...