I'm trying to add a semi-transparent black overlay on the site except for a transparent circular area. Image bellow.
I have tried with different parent-children relationships and opacity settings without success. Is there a way to do with css or javascript?
Edit: This is the code I'm working on. The black circle should be transparent. https://jsfiddle.net/f47oto4o/
html:
<div>
<p>
This should be shown
</p>
</div>
<div class="overlay">
<div class="transparent-circle"></div>
</div>
css:
p {
margin-top: 200px;
text-align: center;
}
.overlay {
background: rgba(0,0,0,0.8);
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
}
.transparent-circle {
position: absolute;
top: 160px;
left: 50%;
height: 100px;
width: 100px;
background: rgba(0,0,0,1.0);
z-index: 2;
border-radius: 100%;
}
Edit 2: Should this be marked as a duplicate? The problem is stated in terms of opacity and transparency rather than cutting holes in divs. This is why I couldn't find a solution to my question originally.