18910140161

HTML-在图库中用视频替换图像-堆栈溢出

顺晟科技

2022-10-18 13:00:37

152

这是我用于图库的代码,基于引导程序的模板

<代码><;DIV类=";COL-MD-4 FTCO-Animate";>;<;DIV类=";库IMG d-flex align-items-end";style=";背景图片:URL(images/gallery/leopardshark.JPG);";>;<;a href=";images/gallery/leopardshark.JPG";类=";图标图像弹出窗口D-Flex调整内容中心对齐项目中心";>;<;span类=";图标-展开";>;<;/span>;<;/a>;<;DIV类=";说明W-100 PX-4<;DIV类=";文本W-100 MB-3 “ ”>;<;/DIV>;<;/DIV>;<;/DIV>;<;/DIV>;

我想用视频替换背景图像,有没有办法做到这一点,并使其在所有浏览器中自动播放?我只需替换图像URL,就可以让MP4在Safari中工作。


顺晟科技:

您可以将IMG替换为:

<代码><;视频自动播放>;<;源SRC=";/路径";类型=";视频/MP4";>;错误消息<;/视频>;

这会在Firefox中自动播放,但不会在Chrome中播放(他们阻止了它)。因此,如果你不想添加控件,你也需要使用这样的东西:

<div class="col-md-4 ftco-animate">
  <div class="gallery img d-flex align-items-end" style="background-image: url(images/gallery/leopardshark.jpg);">
    <a href="images/gallery/leopardshark.jpg" class="icon image-popup d-flex justify-content-center align-items-center">
      <span class="icon-expand"></span></a>
    <div class="desc w-100 px-4">
      <div class="text w-100 mb-3">
      </div>
    </div>
  </div>
</div>
  • TAG:
相关文章
我们已经准备好了,你呢?
2024我们与您携手共赢,为您的企业形象保驾护航