<script type="module" src="https://unpkg.com/ionicons@7.1.0/dist/ionicons/ionicons.esm.js"></script>
<script nomodule src="https://unpkg.com/ionicons@7.1.0/dist/ionicons/ionicons.js"></script>
<div class="video-background">
<video id="bgVideo" autoplay muted loop playsinline>
<source src="https://cdn.coverr.co/videos/coverr-aerial-view-of-beautiful-resort-2458/1080p.mp4" type="video/mp4">
Your browser does not support the video tag.
</video>
</div>
<div class="overlay" id="overlay"></div>
<div class="content">
<div class="hero-content">
<h1>Full Screen Video Background</h1>
<p>Create stunning immersive experiences with full screen video backgrounds. Perfect for landing pages, portfolios, and modern websites.</p>
<a href="#" class="cta-button">
<ion-icon name="rocket-outline"></ion-icon>
Get Started
</a>
</div>
<div class="scroll-indicator">
<ion-icon name="chevron-down-outline"></ion-icon>
</div>
</div>
<div class="volume-control">
<div class="control-btn" id="volumeBtn" title="Toggle Sound">
<ion-icon name="volume-mute-outline" id="volumeIcon"></ion-icon>
</div>
<input type="range" class="volume-slider" id="volumeSlider" min="0" max="100" value="0">
</div>
<div class="video-controls">
<div class="control-btn" id="playPauseBtn" title="Play/Pause">
<ion-icon name="pause-outline" id="playIcon"></ion-icon>
</div>
<div class="control-btn" id="restartBtn" title="Restart">
<ion-icon name="refresh-outline"></ion-icon>
</div>
</div>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
overflow-x: hidden;
}
.video-background {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
overflow: hidden;
z-index: -1;
}
#bgVideo {
position: absolute;
top: 50%;
left: 50%;
min-width: 100%;
min-height: 100%;
width: auto;
height: auto;
transform: translate(-50%, -50%);
object-fit: cover;
}
.overlay {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.4);
z-index: 0;
transition: background 0.3s;
}
.content {
position: relative;
z-index: 1;
min-height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 40px 20px;
text-align: center;
color: white;
}
.hero-content {
max-width: 800px;
}
h1 {
font-size: 64px;
font-weight: 700;
margin-bottom: 20px;
text-shadow: 2px 2px 20px rgba(0, 0, 0, 0.5);
animation: fadeInUp 0.8s ease-out;
}
p {
font-size: 24px;
margin-bottom: 40px;
text-shadow: 1px 1px 10px rgba(0, 0, 0, 0.5);
line-height: 1.6;
animation: fadeInUp 0.8s ease-out 0.2s both;
}
.cta-button {
display: inline-flex;
align-items: center;
gap: 10px;
padding: 16px 40px;
background: white;
color: #1a202c;
text-decoration: none;
border-radius: 50px;
font-size: 18px;
font-weight: 600;
transition: all 0.3s;
box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
animation: fadeInUp 0.8s ease-out 0.4s both;
}
.cta-button:hover {
transform: translateY(-3px);
box-shadow: 0 6px 25px rgba(0, 0, 0, 0.4);
background: #f7fafc;
}
.video-controls {
position: fixed;
bottom: 40px;
right: 40px;
display: flex;
gap: 12px;
z-index: 2;
}
.control-btn {
width: 50px;
height: 50px;
border-radius: 50%;
background: rgba(255, 255, 255, 0.2);
backdrop-filter: blur(10px);
border: 1px solid rgba(255, 255, 255, 0.3);
color: white;
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
transition: all 0.3s;
font-size: 24px;
}
.control-btn:hover {
background: rgba(255, 255, 255, 0.3);
transform: scale(1.1);
}
.control-btn:active {
transform: scale(0.95);
}
.volume-control {
position: fixed;
bottom: 40px;
left: 40px;
display: flex;
align-items: center;
gap: 12px;
z-index: 2;
}
.volume-slider {
width: 100px;
height: 6px;
border-radius: 3px;
background: rgba(255, 255, 255, 0.3);
outline: none;
-webkit-appearance: none;
cursor: pointer;
}
.volume-slider::-webkit-slider-thumb {
-webkit-appearance: none;
appearance: none;
width: 16px;
height: 16px;
border-radius: 50%;
background: white;
cursor: pointer;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}
.volume-slider::-moz-range-thumb {
width: 16px;
height: 16px;
border-radius: 50%;
background: white;
cursor: pointer;
border: none;
}
@keyframes fadeInUp {
from {
opacity: 0;
transform: translateY(30px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
.scroll-indicator {
position: absolute;
bottom: 40px;
left: 50%;
transform: translateX(-50%);
animation: bounce 2s infinite;
}
.scroll-indicator ion-icon {
font-size: 32px;
color: white;
filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.3));
}
@keyframes bounce {
0%, 20%, 50%, 80%, 100% {
transform: translateX(-50%) translateY(0);
}
40% {
transform: translateX(-50%) translateY(-10px);
}
60% {
transform: translateX(-50%) translateY(-5px);
}
}
@media (max-width: 768px) {
h1 {
font-size: 42px;
}
p {
font-size: 18px;
}
.video-controls {
bottom: 20px;
right: 20px;
}
.volume-control {
bottom: 20px;
left: 20px;
}
.control-btn {
width: 45px;
height: 45px;
font-size: 20px;
}
}
const video = document.getElementById('bgVideo');
const playPauseBtn = document.getElementById('playPauseBtn');
const playIcon = document.getElementById('playIcon');
const restartBtn = document.getElementById('restartBtn');
const volumeBtn = document.getElementById('volumeBtn');
const volumeIcon = document.getElementById('volumeIcon');
const volumeSlider = document.getElementById('volumeSlider');
const overlay = document.getElementById('overlay');
let isPlaying = true;
let isMuted = true;
// Play/Pause functionality
playPauseBtn.addEventListener('click', () => {
if (isPlaying) {
video.pause();
playIcon.name = 'play-outline';
isPlaying = false;
} else {
video.play();
playIcon.name = 'pause-outline';
isPlaying = true;
}
});
// Restart functionality
restartBtn.addEventListener('click', () => {
video.currentTime = 0;
if (!isPlaying) {
video.play();
playIcon.name = 'pause-outline';
isPlaying = true;
}
});
// Volume toggle
volumeBtn.addEventListener('click', () => {
if (isMuted) {
video.muted = false;
video.volume = volumeSlider.value / 100;
volumeIcon.name = video.volume > 0.5 ? 'volume-high-outline' : 'volume-low-outline';
isMuted = false;
if (volumeSlider.value == 0) {
volumeSlider.value = 50;
video.volume = 0.5;
}
} else {
video.muted = true;
volumeIcon.name = 'volume-mute-outline';
isMuted = true;
}
});
// Volume slider
volumeSlider.addEventListener('input', (e) => {
const volume = e.target.value / 100;
video.volume = volume;
video.muted = false;
isMuted = false;
if (volume === 0) {
volumeIcon.name = 'volume-mute-outline';
} else if (volume > 0.5) {
volumeIcon.name = 'volume-high-outline';
} else {
volumeIcon.name = 'volume-low-outline';
}
});
// Adjust overlay darkness on scroll
window.addEventListener('scroll', () => {
const scrolled = window.scrollY;
const maxScroll = 300;
const opacity = Math.min(0.4 + (scrolled / maxScroll) * 0.3, 0.7);
overlay.style.background = `rgba(0, 0, 0, ${opacity})`;
});
// Ensure video plays on load
video.play().catch(err => {
console.log('Autoplay prevented:', err);
});
No comments yet. Be the first!