Created
January 12, 2017 20:05
-
-
Save torbentschechne/6bae7b9853112af03fe1e83227511e16 to your computer and use it in GitHub Desktop.
Vimeo - Full-width background wrapper
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
<div class="iframe-wrapper"> | |
<iframe src="https://player.vimeo.com/video/123456789?autoplay=1&loop=1&byline=0&title=0"> | |
</div> | |
/* Makes a fixed background wrapper | |
which the user cannot interact with */ | |
.iframe-wrapper { | |
position: fixed; | |
top: 0; | |
left: 0; | |
width: 100%; | |
height: 100%; | |
z-index: -1; | |
pointer-events: none; | |
overflow: hidden; | |
} | |
/* Make the iframe keep an aspect ratio, and | |
position it in the middle of its parent wrapper*/ | |
.iframe-wrapper iframe { | |
width: 100vw; | |
height: 56.25vw; /* Given a 16:9 aspect ratio, 9/16*100 = 56.25 */ | |
min-height: 100vh; | |
min-width: 177.77vh; /* Given a 16:9 aspect ratio, 16/9*100 = 177.77 */ | |
position: absolute; | |
top: 50%; | |
left: 50%; | |
transform: translate(-50%, -50%); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment