I’m making a tutorial on how to use my app for the first time.
So it looks like a popup about how to use a button
during the tutorial, I want to make the background darker and a circle appears that will circle the button and there is a tutorial text
So, I want to make a container that has circular holes
here’s a simple example:
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
*{
margin: 0;
padding: 0;
}
.dark{
height: 100%;
width: 100%;
position: fixed;
background-color: rgba(0, 0, 0, 0.377);
}
.circle{
height: 150px;
width: 150px;
border-radius: 50%;
background-color: white;
}
</style>
</head>
<body>
<div class="dark">
<p style="color:white;font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;font-size: 23px;">This button is used to delete your file.</p>
<div class="circle"></div>
</div>
<button style="margin:200px;">The Button</button>
</body>
but I want the hole to be in the button
2
Answers
Update
Updated the code example to contain the overlay by adding a
<main>
container withoverflow: hidden
, so the snippet displays more properly.Original
Just posting as an alternative solution:
After some experiments, I came up with this new method that actually display a transparent circle instead of one with a white background, hopefully it’s closer to the desired behavior of a hole.
This allows other elements beside the button to be seen through, and it also keeps the button interactive so it can accept hover and click effects properly.
Run this snippet to see the result: