Skip to content

Instantly share code, notes, and snippets.

@dillon
Last active October 3, 2019 18:58
Show Gist options
  • Save dillon/3cf0f6f0b616ca55d716b9c78a35ee02 to your computer and use it in GitHub Desktop.
Save dillon/3cf0f6f0b616ca55d716b9c78a35ee02 to your computer and use it in GitHub Desktop.
// note: video doesn't autoplay when iOS's battery saving mode is on
const VideoContainer = styled.div`
position: absolute;
top: 0;
bottom: 0;
width: 100%;
height: 100%;
overflow: hidden;
z-index: -1;
pointer-events: none;
>div>div span {
display: none;
}
video {
@media (min-aspect-ratio: 16/9) {
width:100%;
height: auto;
}
@media (max-aspect-ratio: 16/9) {
width:auto;
height: 100%;
}
/* Center the video */
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%,-50%);
opacity: ${ ({ loading }) => loading ? 0 : 1 };
transition: opacity ${ animations.slowSpeed } ease-in-out;
}
`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment