我在台式机上以全屏模式运行浏览器(chrome)。我正在尝试使用CSS使视频适合屏幕的宽度和高度。但是,我可以在屏幕的最右侧看到一条1px的垂直线,该垂直线未被视频覆盖。这是我的HTML
。我也尝试将视频的宽度和高度直接设置为screen.width;
和screen.height;
,但得到的结果完全相同。
<body>
<div class="fill-screen">
<video id="57" autoplay="" loop="" class="asset current"><source src="myvideo.mp4"></video>
</div>
</body>
和我的CSS:
* { cursor: none !important; }
body{
margin:0px !important;
}
.hidden{
display:none;
}
div.fill-screen {
position: absolute;
left: 0;
right: 0;
top: 0;
bottom: 0;
text-align: center;
}
video{
/* prevent browser from warping video */
width: 100% !important;
height: 100% !important;
}
最佳答案
试试下面的代码:
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
* {
box-sizing: border-box;
}
body {
margin: 0;
font-family: Arial;
font-size: 17px;
}
#myVideo {
position: fixed;
right: 0;
bottom: 0;
min-width: 100%;
min-height: 100%;
}
.content {
position: fixed;
bottom: 0;
background: rgba(0, 0, 0, 0.5);
color: #f1f1f1;
width: 100%;
padding: 20px;
}
</style>
</head>
<body>
<video autoplay muted loop id="myVideo">
<source src="https://www.w3schools.com/howto/rain.mp4" type="video/mp4">
Your browser does not support HTML5 video.
</video>
</body>
</html>
更多信息:https://www.w3schools.com/howto/howto_css_fullscreen_video.asp
关于javascript - 视频未填满页面宽度,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/58281375/