js响应性不工作在小屏幕上

Video.js Responsiveness doesnot work on small screen

本文关键字:屏幕 工作 响应 js      更新时间:2023-09-26

我已经制作了这个bin,我试图使我的video.js响应。请让我知道我该怎么做。我尝试了很多,但在移动视图,它的控制总是浮出播放器,不坚持自己的位置:http://jsbin.com/idinaf/627/edit

videojs.autoSetup();
videojs('example_video_1').ready(function(){
  console.log(this.options()); //log all of the default videojs options
   // Store the video object
  var myPlayer = this, id = myPlayer.id();
  // Make up an aspect ratio
  var aspectRatio = 264/640; 
  function resizeVideoJS(){
    var width = document.getElementById(id).parentElement.offsetWidth;
    myPlayer.width(width).height( width * aspectRatio );
  }
  // Initialize resizeVideoJS()
  resizeVideoJS();
  // Then on resize call resizeVideoJS()
  window.onresize = resizeVideoJS; 
});

对于较小的屏幕,您应该使用媒体查询来更改播放器控件的css。我就是这样做的,而且很有效。