Created
December 22, 2015 09:49
-
-
Save julienchazal/7aaaa329df8fbd28dc1f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// http://fvsch.com/code/video-background/ | |
#video-bg { | |
position: fixed; | |
top: 0; right: 0; bottom: 0; left: 0; | |
overflow: hidden; | |
} | |
#video-bg > video { | |
position: absolute; | |
top: 0; | |
left: 0; | |
width: 100%; | |
height: 100%; | |
} | |
/* 1. No object-fit support: */ | |
@media (min-aspect-ratio: 16/9) { | |
#video-bg > video { height: 300%; top: -100%; } | |
} | |
@media (max-aspect-ratio: 16/9) { | |
#video-bg > video { width: 300%; left: -100%; } | |
} | |
/* 2. If supporting object-fit, overriding (1): */ | |
@supports (object-fit: cover) { | |
#video-bg > video { | |
top: 0; left: 0; | |
width: 100%; height: 100%; | |
object-fit: cover; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment