I am trying to create a full-width iframe vimeo background covered by a pattern located in my body div. The video is covered by an overlay so it becomes unclickable. Ive tried g
This solution replicates the css property background-size: cover
, using an iframe instead of an image, in full CSS.
First, put your vimeo iframe in a wrapper:
Then apply those styles:
/* 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%);
}
In addition, in the case of Vimeo, a pro account gives you the ability to remove the player's controls.