调整窗口大小时重复背景图像(背景重复不重复)

azh*_*hpo 1 html css

我的背景图像重复,即使在css我有 background-repeat: no-repeat;

为什么会这样?

当我调整窗口大小时会发生这种情况.

我在背景上有一台电视视频图层.

HTML:

<div class="tv">
   <video width="98%" height="78%" controls="controls">
          <source src="img/showreel.mp4" type="video/mp4">
   </video>
</div>
Run Code Online (Sandbox Code Playgroud)

CSS:

.tv{
  text-align: center;
  position:relative;
  background-repeat: no-repeat;
  background: url(img/tv.png) center center;
  background-size: 100%;
  height: 650px;
  width: 100%;
}

.showreel-video{
  position:relative;
  margin-top: -40px;
}
Run Code Online (Sandbox Code Playgroud)

Gui*_*ume 8

您的background-repeat: no-repeat;指令当前被background:...;属性覆盖,因为后者也接受重复/不重复指令并放在后面.

因此,您必须在背景属性中添加no-repeat,如下所示:

background: url(http://lorempixel.com/400/200/) center center no-repeat;
Run Code Online (Sandbox Code Playgroud)

或background-repeat: no-repeat;在后台指令后移动.