Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/39.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 在背景视频的顶部,使用CSS将图像水平居中_Html_Css - Fatal编程技术网

Html 在背景视频的顶部,使用CSS将图像水平居中

Html 在背景视频的顶部,使用CSS将图像水平居中,html,css,Html,Css,新的编码。 我已将视频设置为在网站背景上自动播放。 当我尝试将图像放置在顶部时,会遇到问题,特别是在尝试将其水平居中时 典型的解决方案会导致图像消失: img.center { display: block; margin: 0 auto; } 以下是我的徽标CSS: .logo { position: absolute; margin-left: auto; margin-right: auto; height: 250px; padding-top

新的编码。 我已将视频设置为在网站背景上自动播放。 当我尝试将图像放置在顶部时,会遇到问题,特别是在尝试将其水平居中时

典型的解决方案会导致图像消失:

img.center {
   display: block;
   margin: 0 auto;
}
以下是我的徽标CSS:

.logo {
   position: absolute;
   margin-left: auto;
   margin-right: auto;
   height: 250px;
   padding-top: 15px;
}
我需要这个标志漂浮在背景视频的顶部,其样式如下:

#bgvideo {
   position: fixed;
   top: 0;
   left: 0;
   bottom: 0;
   min-width: 100%;
   min-height: 100%;
}

就这么简单。这是一张工作票

HTML:


位置:绝对位置;最高:50%;左:50%;转换:翻译(-50%,-50%)<video autoplay muted loop id="myVideo">
  <source src="https://www.w3schools.com/howto/rain.mp4" type="video/mp4">
</video>
<img id="myImg" src="https://www.searchenginegenie.com/images/29-samplelogo.jpg" width="200">
#myVideo {
    position: fixed;
    right: 0;
    bottom: 0;
    min-width: 100%; 
    min-height: 100%;
}
#myImg {
    position: absolute;
    left: 0;
    right: 0;
    display: block;
    margin: auto; 
}