我有以下代码:
<div class="row front-page-img">
<img class="img-responsive" src="http://www.echomountainresort.com/wp-content/uploads/2014/10/echo-mountain-concert_banner_bg.jpg" style="box-shadow: rgba(0,0,0,.2) 3px 5px 5px;">
<div class="front-page-container-search">
<h3>This is the text that I wish could be solid white, but instead it is transparent</h3>
<form>
<div class="input-group">
<input type="text" class="form-control">
<span class="input-group-btn">
<button class="btn btn-default" type="submit">
<span class="glyphicon glyphicon-search"></span>
</button>
</span>
</div>
</form>
</div>
</div>
.front-page-img {
margin-right: 0px;
}
.front-page-container-search{
position:absolute;
left: 50px;
right:50px;
width: 200px;
color: white;
text-align: center;
top: 75px;
background-color: rgba(0, 0, 0, 0.6);
border: 1px solid black;
opacity: 0.7;
margin: 0 auto;
}
正如您在我的jsFiddle中看到的here我的文字不是纯白色,我的输入是透明的。理想情况下,我希望有纯白色文本和可靠的输入。我试图使用这个较旧的question中接受的答案并尝试使用z-index,但没有运气。任何帮助表示赞赏。
答案 0 :(得分:2)
将不透明度设置为1并正确包装div。这是小提琴。 https://jsfiddle.net/n6qzsttL/
<div class="row front-page-img ng-scope">
<img class="img-responsive" src="http://www.echomountainresort.com/wp-content/uploads/2014/10/echo-mountain-concert_banner_bg.jpg" style="box-shadow: rgba(0,0,0,.2) 3px 5px 5px;">
<div class="front-page-container-search">
<h3>This is the text that I wish could be solid white, but instead it is transparent</h3>
</div>
<form>
<div class="input-group">
<input type="text" class="form-control"> <span class="input-group-btn">
<button class="btn btn-default" type="submit">
<span class="glyphicon glyphicon-search"></span>
</button>
</span>
</div>
</form>
和CSS
.front-page-img {
margin-right: 0px;
}
.front-page-container-search {
position:absolute;
left: 50px;
right:50px;
width: 200px;
color: white;
text-align: center;
top: 75px;
background-color: rgba(0, 0, 0, 0.6);
border: 1px solid black;
opacity: 1;
margin: 0 auto;
}
答案 1 :(得分:1)
您的z-index没有任何问题。您将.front-page-container-search
的操作设置为0.7
。这就像它在锡上说的那样;它使用0.7
的不透明度渲染元素 - 包括其中的所有内容。
如果您不希望不透明度通过子项传播,请不要在父项上设置它。删除此属性,您的文本和输入将为纯白色。
答案 2 :(得分:1)
目前您使用opacity
.front-page-container-search
作为0.7.
1
请使用0.7
代替.front-page-container-search{
/* Theoretically for IE 8 & 9 (more valid) */
/* ...but not required as filter works too */
/* should come BEFORE filter */
-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)"; // IE8
/* This works in IE 8 & 9 too */
/* ... but also 5, 6, 7 */
filter: alpha(opacity=100); // IE 5-7
/* Modern Browsers */
opacity:1;
}
。
var win = window.open(URL, windowName, 'resizable=no');
win.resizeTo(*yourWidth*, *yourHeight*);