简体   繁体   English

视频/图像滑块调整大小以适合屏幕(宽度和高度)

[英]Video/Image Slider resize to fit screen (both width and height)

I'm using this slider code to show my image and video: 我正在使用以下滑块代码显示图像和视频:

Code: https://codepen.io/1wdtv/pen/jbjZeb Code: https Code: //codepen.io/1wdtv/pen/jbjZeb

However the problem is that the slider is only responsive when it comes to the width. 但是,问题在于滑块仅在宽度时才响应。 meaning if you resize your browser it will resize the image/video with it, without taking into regards its Height. 这意味着,如果您调整浏览器的大小,它将在不考虑其高度的情况下随其调整图像/视频的大小。

Is it possible to make the video/image fit exactly the screen from the height and width? 是否可以使视频/图像从高度和宽度完全适合屏幕?

I want them to show on the screen witout having to scroll down in order to see the rest of the video/image. 我希望它们在屏幕上显示,而不必向下滚动才能查看其余的视频/图像。 even if it meant stretching the video/image 即使这意味着拉伸视频/图像

Thank you 谢谢

You can add this to your CSS: 您可以将其添加到CSS中:

.slider-video {
  height: 100%;
}
video { 
  object-fit: fill;
}

This will make it take up the entire height. 这将使其占据整个高度。 And it will stretch to fill the width. 它将拉伸以填充宽度。 This may skew the video but you said that was acceptable. 这可能会使视频倾斜,但是您说可以接受。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM