All, I have some video playing on my website, and I want it to play width: 100%; height: 600px; but nothing I have tried has worked so far.
我在我的网站上放了一些视频,我希望它的宽度是100%;身高:600 px;但到目前为止,我还没有尝试过什么。
When I set the height: 600px; the width of the video is proportionate. I basically want to achieve the same effect as background-size: cover, with a height of 600px. I am using inline CSS, and that part can be changed, but I am more concerned with how to achieve a custom height and width of a video, if even possible. Thank you.
设置高度:600px;视频的宽度是成比例的。我基本上想要达到和背景一样的效果:覆盖,高度600像素。我正在使用内联CSS,这部分可以修改,但我更关心如何实现视频的自定义高度和宽度,如果可能的话。谢谢你!
ANY help is highly appreciated. Here is my code for the
非常感谢您的帮助。这是我的
的代码
1 个解决方案
#1
8
One way to accomplish this is to wrap the video in a div and give that the height of 600px and overflow: hidden.
实现这一点的一种方法是将视频封装在一个div中,并给出600px和溢出的高度:隐藏。
For example:
例如:
Note that the video may be cut off towards the bottom if its proportionate height is greater than 600px and that the more you stretch the window, the more the video will be cut off.
请注意,如果视频的比例高度大于600px,那么视频可能会被切向底部,而且你拉伸窗口的时间越长,视频就越会被切掉。
Here is a jsFiddle using this code:
下面是一个使用此代码的jsFiddle: