日期:2014-05-17  浏览次数:20605 次

input背景透明的穿透问题
HTML code

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<style type="text/css">
.box{position:relative;}
.bg{position:absolute; left:5px; top:5px; z-index:-1; font-size:12px;}
input{
    height:20px;
    background-color:transparent;
    border: 1px solid #F00;
}
</style>
</head>

<body>
<div class="box"><span onClick="alert('我是背景')" class="bg">文明扯淡,利国利民。</span><input type="text" /></div>
</body>
</html>



当一个input框背景透明时(background-color:transparent;),在ie下会被穿透,而在chrome等浏览器下则不会,有什么方法可以解决?

------解决方案--------------------
探讨

可以用半透明的图片作为input的背景,而不是用文字,就可以解决

------解决方案--------------------
把input中的背景图片设置成和div的背景图片相同的即可