微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

由于 javascript 或 css 错误,Webm 视频没有以正确的宽度显示

如何解决由于 javascript 或 css 错误,Webm 视频没有以正确的宽度显示

我有一堆 Webm 视频,在显示时我希望它们覆盖整个屏幕。高度正确但宽度太短,无论我更改什么边距或宽度值,我都开始相信这不是 CSS 问题。 (视频为 1920 x 1080 像素)。解决方案可能很简单,但我对编程比较陌生。任何帮助将不胜感激!

HTML:

  <style>
        
        body {
    background-image: url('videos/fondo.jpg');
    background-repeat: no-repeat;
    background-size: cover;
    background-color: black;
}

</style>
    
</head>

<body>
    <div id="letters">

<!--b1-->


        <video id="b1" preload="auto" autoplay="true">
            <source src="videos/b1.webm" type="video/webm">
            Video not supported
            
        </video>
    
    <!--p1-->


        <video id="p1" preload="auto" autoplay="true">
            <source src="videos/p1.webm" type="video/webm">
            Video not supported
            
        </video>
    
    <!--k1-->


        <video id="k1" preload="auto" autoplay="true">
            <source src="videos/k1.webm" type="video/webm">
            Video not supported
            
        </video>
    
    <!--g1-->


        <video id="g1" preload="auto" autoplay="true">
            <source src="videos/g1.webm" type="video/webm">
            Video not supported
            
        </video>
    
    <!--z1-->


        <video id="z1" preload="auto" autoplay="true">
            <source src="videos/z1.webm" type="video/webm">
            Video not supported
            
        </video>
    
    <!--x1-->


        <video id="x1" preload="auto" autoplay="true">
            <source src="videos/x1.webm" type="video/webm">
            Video not supported
            
        </video>
    
     <!--d1-->
    
     <video id="d1" preload="auto" autoplay="true">
            <source src="videos/d1.webm" type="video/webm">
            Video not supported
            
        </video>
    
     <!--f1-->
    
     <video id="f1" preload="auto" autoplay="true">
            <source src="videos/f1.webm" type="video/webm">
            Video not supported
            
        </video>
    
    <!--m1-->
    
     <video id="m1" preload="auto" autoplay="true">
            <source src="videos/m1.webm" type="video/webm">
            Video not supported
            
        </video>
    
    <!--q1-->
    
     <video id="q1" preload="auto" autoplay="true">
            <source src="videos/q1.webm" type="video/webm">
            Video not supported
            
        </video>
    
    <!--v1-->
    
     <video id="v1" preload="auto" autoplay="true">
            <source src="videos/v1.webm" type="video/webm">
            Video not supported
            
        </video>
    
    <!--s1-->
    
     <video id="s1" preload="auto" autoplay="true">
            <source src="videos/s1.webm" type="video/webm">
            Video not supported
            
        </video>
    
    <!--t1-->
    
     <video id="t1" preload="auto" autoplay="true">
            <source src="videos/t1.webm" type="video/webm">
            Video not supported
            
        </video>
    
    <!--j1-->
    
     <video id="j1" preload="auto" autoplay="true">
            <source src="videos/j1.webm" type="video/webm">
            Video not supported
            
        </video>
    
    <!--e1-->
    
     <video id="e1" preload="auto" autoplay="true">
            <source src="videos/e1.webm" type="video/webm">
            Video not supported
            
        </video>

    
    <!--i1-->
    
     <video id="i1" preload="auto" autoplay="true">
            <source src="videos/i1.webm" type="video/webm">
            Video not supported
            
        </video>
    
    <!--y1-->
    
     <video id="y1" preload="auto" autoplay="true">
            <source src="videos/y1.webm" type="video/webm">
            Video not supported
            
        </video>
    
    <!--a1-->
    
     <video id="a1" preload="auto" autoplay="true">
            <source src="videos/a1.webm" type="video/webm">
            Video not supported
            
        </video>
    
    <!--u1-->
    
     <video id="u1" preload="auto" autoplay="true">
            <source src="videos/u1.webm" type="video/webm">
            Video not supported
            
        </video>
    
    <!--w1-->
    
     <video id="w1" preload="auto" autoplay="true">
            <source src="videos/W1.webm" type="video/webm">
            Video not supported
            
        </video>
    
    <!--h1-->
    
     <video id="h1" preload="auto" autoplay="true">
            <source src="videos/h1.webm" type="video/webm">
            Video not supported
            
        </video>
    
    <!--r1-->
    
     <video id="r1" preload="auto" autoplay="true">
            <source src="videos/r1.webm" type="video/webm">
            Video not supported
            
        </video>
    

        </div>
    
<script src="animations.js"></script>
</body>
</html>

CSS:

  #letters{
  position: fixed; 
  min-width: 100%;  
  min-height: 100%; 
  width: 100%;
  right: 0; 
  bottom: 0; 
                 
            }
    
#letters video {
  max-height: 100%;
  max-width: 100%;
  width: 100%;
  margin-left: 0%;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%,-50%);
}

JS:

var videos = {
    'b': document.getElementById('b1'),'p': document.getElementById('p1'),'k': document.getElementById('k1'),'g': document.getElementById('g1'),'z': document.getElementById('z1'),'x': document.getElementById('x1'),'d': document.getElementById('d1'),'f': document.getElementById('f1'),'m': document.getElementById('m1'),'q': document.getElementById('q1'),'v': document.getElementById('v1'),'s': document.getElementById('s1'),'t': document.getElementById('t1'),'j': document.getElementById('j1'),'e': document.getElementById('e1'),'i': document.getElementById('i1'),'y': document.getElementById('y1'),'a': document.getElementById('a1'),'u': document.getElementById('u1'),'w': document.getElementById('w1'),'h': document.getElementById('h1'),'r': document.getElementById('r1'),}

document.addEventListener('keypress',e => {
    let video = videos[e.key];
    if (video) {
        video.play();
        video.currentTime = 0;
        $(video).hide();
        
    }   
});

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。