Full size Vimeo background cover

Size
2,491 Kb
Views
30,360

How do I make an full size vimeo background cover?

This a full viewport size video (background) that acts like background-size: cover; when resized. What is a full size vimeo background cover? How do you make a full size vimeo background cover? This script and codes were developed by Henri Peetsmann on 09 December 2022, Friday.

Full size Vimeo background cover Previews

Full size Vimeo background cover - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Full size Vimeo background cover</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <div class="videobg"> <div class="videobg-width"> <div class="videobg-aspect"> <div class="videobg-make-height"> <div class="videobg-hide-controls"> <iframe src="https://player.vimeo.com/video/8970192?autoplay=1&loop=1&title=0&byline=0&portrait=0" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe> </div> </div> </div> </div>
</div> <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script> <script src="js/index.js"></script>
</body>
</html>

Full size Vimeo background cover - Script Codes CSS Codes

/* Quick reset */
* { margin: 0; padding: 0; box-sizing: border-box;
}
/* Make elements as high as viewport */
html { height: 100%;
}
body { position: relative; height: 100%;
}
/* Video background */
.videobg { position: relative; width: 100%; /* Set video container element width here */ height: 100%; /* Set video container element height here */ overflow: hidden; background: #111; /* bg color, if video is not high enough */
}
/* horizontally center the video */
.videobg-width { position: absolute; width: 100%; /* Change width value to cover more area*/ height: 100%; left: -9999px; right: -9999px; margin: auto;
}
/* set video aspect ratio and vertically center */
.videobg-aspect { position: absolute; width: 100%; height: 0; top: -9999px; bottom: -9999px; margin: auto; padding-bottom: 56.25%; /* 16:9 ratio */ overflow: hidden;
}
.videobg-make-height { position: absolute; top: 0; right: 0; bottom: 0; left: 0;
}
.videobg-hide-controls { box-sizing: content-box; position: relative; height: 100%; width: 100%; /* Vimeo timeline and play button are ~55px high */ padding: 55px 97.7777px; /* 16:9 ratio */ top: -55px; left: -97.7777px; /* 16:9 ratio */
}
.videobg iframe { position: absolute; width: 100%; height: 100%; top: 0; left: 0; border: 0 none;
}

Full size Vimeo background cover - Script Codes JS Codes

var timeoutId;
var $videoBgAspect = $(".videobg-aspect");
var $videoBgWidth = $(".videobg-width");
var videoAspect = $videoBgAspect.outerHeight() / $videoBgAspect.outerWidth();
function videobgEnlarge() { console.log('resize'); windowAspect = ($(window).height() / $(window).width()); if (windowAspect > videoAspect) { $videoBgWidth.width((windowAspect / videoAspect) * 100 + '%'); } else { $videoBgWidth.width(100 + "%") }
}
$(window).resize(function() { clearTimeout(timeoutId); timeoutId = setTimeout(videobgEnlarge, 100);
});
$(function() { videobgEnlarge();
});
Full size Vimeo background cover - Script Codes
Full size Vimeo background cover - Script Codes
Home Page Home
Developer Henri Peetsmann
Username henripeetsmann
Uploaded December 09, 2022
Rating 3
Size 2,491 Kb
Views 30,360
Do you need developer help for Full size Vimeo background cover?

Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!

Henri Peetsmann (henripeetsmann) Script Codes
Create amazing web content with AI!

Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!