简体   繁体   English

z-index 和不透明度 - 如何隐藏 div

[英]z-index and opacity - how to hide the div

Trying to make a website with a friend of mine and we're having problems with the divs at other divs with opacity.试图与我的一个朋友一起创建一个网站,但我们在其他不透明的 div 中遇到了 div 问题。

Here's a picture to make it clear:这是一张图片,可以清楚地说明:

在此处输入图片说明

As you can see, the circle (div) is visible through the black bar.如您所见,通过黑条可以看到圆圈 (div)。 But we want it to be as on the left side of the picture.但我们希望它像图片的左侧那样。

Any ideas how to fix it?任何想法如何解决它?

//The black bar
.top-bar {
    width: 100%;
    height: 100px;
    background-color: black;
opacity: 0.8;
}

//A circle
.textbox_how {
    width: 820px;
    height: 820px;
    border: 20px #e8c499 solid;
    border-radius: 100%;
    left: 50%;
    position: absolute;
    top: 5%;
    text-align: center;
    z-index: -1;
}

//The other circle
.textbox_how_around {
    width: 840px;
    height: 840px;
    border: 10px brown solid;
    border-radius: 100%;
    left: 50%;
    position: absolute;
    top: 5%;
    text-align: center;
    z-index: -1;
}

@trunks175 is correct. @trunks175 是正确的。 Put a dummy behind the header with a white background.在带有白色背景的标题后面放一个假人。

<div style="position:absolute;top:0;left:0;opacity:0.5;background:red;height:300px;width:300px;z-index:3"></div>
<div style="position:absolute;top:0;left:0;background:white;border:1px solid green;height:300px;width:300px;z-index:2"></div>
<div style="position:absolute;top:100px;left:100px;background:blue;height:300px;width:300px;z-index:1"></div>

Here's a fiddle: http://jsfiddle.net/teRcg/1/这是一个小提琴: http : //jsfiddle.net/teRcg/1/

I believe this is the only way to achieve what you're trying to since the header is opaque.我相信这是实现您想要实现的目标的唯一方法,因为标题是不透明的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM