视频未居中,JS导致它

Video not centered, JS causing it?

本文关键字:JS 视频      更新时间:2023-09-26

如果你看这个页面:http://www.groenesmoothiehandboek.nl/sp/你会看到视频稍微偏离中心。

您还将看到上面有一个计数器(翻转时钟.js)。要调用计数器,我们使用以下代码:

<div style="width:100%; background:url(img/bg-countdown.png) center top no-repeat; height:140px; margin:0 auto; z-index:9999;">

如果我删除这部分,视频中心完美。

我已经在尝试修复这个小错误一个多小时但没有成功。

有谁知道我该如何解决这个问题?

提前感谢!

如果你包装这个div:

<!-- notice no height attribute here -->
<div style="width:100%; background:url(img/bg-countdown.png) center top no-repeat; margin:0 auto; z-index:9999;">
  <!-- stuff from inside this div -->
</div>

在这个div内部:

<div style="height: 140px;">
  <!-- Place the entire div from above here -->
</div>

您的问题已修复。

图片:https://i.stack.imgur.com/R6RcJ.png

我想我为您解决了这个问题:

float: left添加到计数器的包装器中。(具有这些属性的那个

{ 
width: 100%;
background: url(img/bg-countdown.png) center top no-repeat;
height: 140px;
margin: 0 auto;
z-index: 9999;
}

将这些添加到其下方的div 中

width: 100%; 
float:left;

(具有这些属性的div):

background:url(img/bg-vid.jpg) center top no-repeat; 
height:878px;
max-width:1920px;
margin:0 auto;

应该修复。我强烈建议您使用类和 id 来添加 CSS :)。这样更具可读性。祝冰沙好运;)