[英]html5 video 100% width & height via javascript
How can I achieve something like this http://themenectar.com/demo/salient-agency/ ?我怎样才能实现这样的事情http://themenectar.com/demo/salient-agency/ ?
Basically it is a responsive video that fit whole dimension of the screen.基本上它是一个适合整个屏幕尺寸的响应式视频。 I tried but without success, my problem is that the video doesn't fit the whole screen size (like the reference website)
我试过但没有成功,我的问题是视频不适合整个屏幕尺寸(如参考网站)
I saw that site and I think I have to use javascript to give the dimensions我看到了那个网站,我想我必须使用 javascript 来给出尺寸
this is my test on codepen http://codepen.io/mp1985/pen/YyawvO这是我对 codepen 的测试http://codepen.io/mp1985/pen/YyawvO
jQuery(document).ready(function($) {
function setHeight() {
windowHeight = $(window).innerHeight();
windowWidth = $(window).innerWidth();
$('.video-wrap, video').css('height', windowHeight);
$('.video-wrap, video').css('width', windowWidth);
}
setHeight();
$(window).resize(function() {
setHeight();
});
});
Many thanks非常感谢
You can use one of this plugins您可以使用此插件之一
http://dfcb.github.io/BigVideo.js/ http://dfcb.github.io/BigVideo.js/
http://vodkabears.github.io/vide/ http://vodkabears.github.io/vide/
https://github.com/matthojo/videojs-Background https://github.com/matthojo/videojs-Background
If you don't have previous experience working with plugins just remember to include jquery
script before plugin script如果您以前没有使用插件的经验,请记住在插件脚本之前包含
jquery
脚本
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.