Skip to content

Instantly share code, notes, and snippets.

@mishelen
Created August 20, 2014 00:34
Show Gist options
  • Select an option

  • Save mishelen/add0b4ed8795375b7a64 to your computer and use it in GitHub Desktop.

Select an option

Save mishelen/add0b4ed8795375b7a64 to your computer and use it in GitHub Desktop.
Mixin for video on all container == background video. Миксина для заполнения видео-бэкграундом.
@mixin stretching-pos($type-pos: absolute) {
left: 0;top: 0;right: 0;bottom: 0;
position: $type-pos;
}
@mixin stretching-hw($type-pos: absolute) {
height: 100%; width: 100%;
position: $type-pos;
}
#video-bg {
@include stretching-pos;
overflow: hidden;
> video {
@include stretching-hw;
top: 0;
left: 0;
@media (min-aspect-ratio: 16/9) {height: 300%; top: -100%;}
@media (max-aspect-ratio: 16/9) {width: 300%; left: -100%;}
@supports (object-fit: cover) {
top: 0; left: 0;
width: 100%; height: 100%;
object-fit: cover;
}
}
}
video(loop, autoplay)
source(type='video/mp4', src='http://fvsch.com/code/video-background/video.mp4')
source(type='video/webm', src='http://fvsch.com/code/video-background/video.webm')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment