<div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code> function showAlert() {
alert('Button clicked!');
}
.button-container {
position: relative;
display: inline-block;
}
.video-background {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
overflow: hidden;
}
.video-background video {
width: 100%;
height: 100%;
object-fit: cover;
}
.transparent-button {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: transparent;
border: none;
cursor: pointer;
}
.button-text {
position: relative;
z-index: 1;
color: #fff;
font-size: 18px;
text-align: center;
padding: 10px 20px;
}
<div class="button-container">
<div class="video-background">
<video autoplay loop muted>
<source src="sample.mp4" type="video/mp4">
</video>
</div>
<button class="transparent-button" onclick="showAlert()">
<div class="button-text">Video Button</div>
</button>
</div>