简体   繁体   English

为什么这段代码中的元素之间有少许空格?

[英]Why is there a slight space between elements in this code?

I have made a hover over effect that works on this image, playing a looped video and showing a text overlay when hovered over.我制作了一个 hover 效果,该效果适用于该图像,播放循环视频并在悬停时显示文本覆盖。 There is a small tiny problem with this.这有一个小问题。 The video is just slightly smaller than the base image, meaning there is tiny gaps between them when the image is hovered over and the video plays.视频略小于基本图像,这意味着当图像悬停在视频上并播放视频时,它们之间会有微小的间隙。 I can't quite figure out why, seeing as the css for the video/text overlay is at width:100%.我不太明白为什么,因为视频/文本覆盖的 css 的宽度为:100%。 If anyone can see what I'm missing I would greatly appreciate the input.如果有人能看到我缺少的东西,我将不胜感激。 Thank you!谢谢! ( (

It's also worth mentioning that this code was written into CARGO.site's (a site building platform) code editor.还值得一提的是,这段代码被写入了 CARGO.site(一个站点构建平台)的代码编辑器中。 {Image 4} is in the place of what would ususally be a html img tag. {图 4} 代替了通常的 html img 标签。 The Javascript might not be relevant but I will include anyway for clarity's sake. Javascript 可能不相关,但为了清楚起见,我还是会包括在内。

A link to the exact site I'm working on: https://racerpictures.cargo.site/work我正在处理的确切站点的链接: https://racerpictures.cargo.site/work

<div class="container-1" gid="13">

<a href="https://racerpictures.cargo.site/easy-life-beeswax" class="image-link-1">
<div class="image-1" gid="1">




<div class="overlay-img-1">

<video id="video-1" autoplay="" loop="" class="">
  <source src="https://files.cargocollective.com/c1549988/A002_C018_0922BW_002.mp4" type="video/mp4">
</video>
    <div class="text-1"><h4>EASY LIFE | BEESWAX<br></h4>
<p class="caption-small-1">MUSIC VIDEO</p>


</div>

  </div>
<div class="base-img-1">
{image 4}
</div>
</div>
</a>
</div>

#video-1 {
    display: block;
    width: 100%;
    height: 100%;
    fit-content: inherit;
 

}

.container-1 {
  position: relative;
    width: 100%;
    margin-bottom: 5px;
   
}

.image-1 {
  display: block;
  width: 100%;
  height: inherit;
}

.overlay-img-1 {
  position: absolute;
  top: 0%;
  bottom: 0;
  left: 0;
  right: 0;
  height: 98.5%;
  width: 100%;
  opacity: 0;
  transition: .5s ease;
  background-color: rgba(0, 0, 0, 0.4);
}

.overlay-img-1:hover {
  opacity: 1;
}

.text-1 {
    width: 100%;

  color: white;
  font-size: 20px;
  position: absolute;
  top: 60%;
  left: 50%;
  -webkit-transform: translate(-50%, -50%);
  -ms-transform: translate(-50%, -50%);
  transform: translate(-50%, -50%);
  text-align: center;
}




<script>

$(document).ready(function() {
  $('.video-1').each(function(el){
    var _this = $(this);
    _this.on('mouseover', function(ev) {
 
      _this[0].src += "&autoplay=1";
      ev.preventDefault();

    });
  });
});
</script>

You can add object-fit: cover;您可以添加object-fit: cover; to the #video-1 .#video-1 For browser support: https://caniuse.com/?search=object-fit .对于浏览器支持: https://caniuse.com/?search=object-fit Also, fit-content is not a css property.此外, fit-content 不是 css 属性。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM