<video poster="https://s3-us-west-2.amazonaws.com/s.cdpn.io/4273/polina.jpg" id="bgvid" playsinline autoplay muted loop>
<!--
- Video needs to be muted, since Chrome 66+ will not autoplay video with sound.
WCAG general accessibility recommendation is that media such as background video play through only once. Loop turned on for the purposes of illustration; if removed, the end of the video will fade in the same way created by pressing the "Pause" button -->
<source src="http://thenewcode.com/assets/videos/polina.webm" type="video/webm">
<source src="http://thenewcode.com/assets/videos/polina.mp4" type="video/mp4">
</video>
<div style="url('https://cdn.matteobruni.it/images/particles/background.jpg')">
<div id="tsparticles"></div>
</div>
body {
margin: 0;
background: #000;
}
video {
position: fixed;
top: 50%;
left: 50%;
min-width: 100%;
min-height: 100%;
width: auto;
height: auto;
z-index: -100;
transform: translateX(-50%) translateY(-50%);
background: url("//demosthenes.info/assets/images/polina.jpg") no-repeat;
background-size: cover;
transition: 1s opacity;
}
.stopfade {
opacity: 0.5;
}
@media screen and (max-width: 500px) {
div {
width: 70%;
}
}
@media screen and (max-device-width: 800px) {
html {
background: url(https://thenewcode.com/assets/images/polina.jpg) #000
no-repeat center center fixed;
}
#bgvid {
display: none;
}
}
#tsparticles {
position: absolute;
width: 100%;
height: 100%;
z-index: 100;
}
tsParticles.load("tsparticles", {
fpsLimit: 60,
particles: {
number: {
value: 100,
density: {
enable: true,
value_area: 800
}
},
color: {
value: "#ffffff"
},
shape: {
type: "circle"
},
opacity: {
value: 1,
random: false
},
size: {
value: 50,
random: true
},
lineLinked: {
enable: true,
distance: 150,
color: "#ffffff",
opacity: 1,
width: 1
},
move: {
enable: true,
speed: 2,
direction: "none",
random: false,
straight: false,
out_mode: "out"
}
},
interactivity: {
detect_on: "window",
events: {
onHover: {
enable: true,
mode: "bubble"
},
onClick: {
enable: true,
mode: "push"
},
resize: true
},
modes: {
grab: {
distance: 400,
lineLinked: {
opacity: 1
}
},
bubble: {
distance: 400,
size: 200,
duration: 2,
opacity: 1,
speed: 3
},
repulse: {
distance: 200
},
push: {
particles_nb: 4
},
remove: {
particles_nb: 2
}
}
},
backgroundMask: {
enable: true,
cover: {
value: {
r: 255,
g: 255,
b: 255
}
}
},
retina_detect: true
});
/*
var vid = document.getElementById("bgvid");
if (window.matchMedia('(prefers-reduced-motion)').matches) {
vid.removeAttribute("autoplay");
vid.pause();
pauseButton.innerHTML = "Paused";
}
function vidFade() {
vid.classList.add("stopfade");
}
vid.addEventListener('ended', function()
{
// only functional if "loop" is removed
vid.pause();
// to capture IE10
vidFade();
});
*/
This Pen doesn't use any external CSS resources.