如何在透明div上设置html输入字段透明?

时间:2012-06-27 08:41:50

标签: css3 opacity rgba html-input css

我有一个div设置透明与rgba并希望在该div上输入字段也具有透明背景。问题是输入字段背景不呈现透明。 如果我在div上使用opacity:0.8;但文本是透明的,那么它是有效的,所以我需要rgba。 对于透明div rgba之外的第二个输入字段。

这是我的示例代码:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Insert title here</title>

<style type="text/css">

.term {
background-color: rgba(0,0,0,0.8);
color: #5fba3d;
width: 200px;
height: 100px;
}

input {
background-color: rgba(0,0,0,0.8);
color: #FFF;
border: none;
}

</style>

</head>

<body>

<div style="background-color:yellow; width:300px;">

   <div class="term">
      Input 1 <input type="text" value="Test" />
   </div>

   <br />

   <input type="text" value="Input 2" />

</div>

</body>
</html>

有什么想法吗?

谢谢!

拿但

2 个答案:

答案 0 :(得分:7)

Hey Nathanael如果我改变rgb值,它的工作正常,所以文字不会透明

input {
background-color: rgba(0,0,0,0.1);
color: red;
border: none;
}

我希望这会对你有所帮助...... 你可以看到演示: - http://jsbin.com/avupaw/16/edit#html,live

答案 1 :(得分:5)

或者只是

input {
    background: none;
    color: red;
    border: none;
}