Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save ayush-that/955fb419b4de1ba78617a9d19eba28c7 to your computer and use it in GitHub Desktop.

Select an option

Save ayush-that/955fb419b4de1ba78617a9d19eba28c7 to your computer and use it in GitHub Desktop.
an image as background and on top of it a video with some opacity
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Image Background with Transparent Video</title>
<style>
body, html {
height: 100%;
margin: 0;
font-family: Arial, sans-serif;
}
.background {
position: relative;
height: 100%;
background-image: url('your-image.jpg'); /* Replace with your image URL */
background-size: cover;
background-position: center;
}
.background video {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 80%; /* Adjust the size as needed */
height: auto; /* Maintain aspect ratio */
opacity: 0.5; /* 50% opacity */
}
</style>
</head>
<body>
<div class="background">
<video autoplay muted loop>
<source src="your-video.mp4" type="video/mp4"> <!-- Replace with your video URL -->
Your browser does not support the video tag.
</video>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment