【发布时间】:2019-12-19 04:34:36
【问题描述】:
我正在尝试让移动设备显示图像而不是视频背景。这是我到目前为止所得到的,但它不起作用。它仍在所有设备上显示视频,我尝试将图像添加为背景,但没有奏效。
这是我的代码: https://jsfiddle.net/8t17jLy0/2/
带有视频代码的js文件在这里:
https://pruebasvirality.000webhostapp.com/js/jquery.vidbacking.js
视频 CSS:
https://pruebasvirality.000webhostapp.com/css/jquery.vidbacking.css
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title></title>
<!-- ALL CSS -->
<link rel="stylesheet" type="text/css" href="https://pruebasvirality.000webhostapp.com/css/bootstrap.css">
<link rel="stylesheet" type="text/css" href="https://pruebasvirality.000webhostapp.com/css/font-awesome.css">
<link rel="stylesheet" type="text/css" href="https://pruebasvirality.000webhostapp.com/css/owl.carousel.css">
<link rel="stylesheet" type="text/css" href="https://pruebasvirality.000webhostapp.com/css/owl.theme.css">
<link rel="stylesheet" type="text/css" href="https://pruebasvirality.000webhostapp.com/css/animate.css">
<link rel="stylesheet" type="text/css" href="https://pruebasvirality.000webhostapp.com/css/slick.css">
<link rel="stylesheet" type="text/css" href="https://pruebasvirality.000webhostapp.com/css/flaticon.css">
<link rel="stylesheet" type="text/css" href="https://pruebasvirality.000webhostapp.com/css/settings.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<link rel="stylesheet" type="text/css" href="https://pruebasvirality.000webhostapp.com/css/style.css" >
<link rel="stylesheet" type="text/css" href="https://pruebasvirality.000webhostapp.com/css/preset.css" >
<link rel="stylesheet" type="text/css" href="https://pruebasvirality.000webhostapp.com/css/responsive.css">
</head>
<body>
<!--BANNER VIDEO BG START-->
<section >
<div class="cid-qTkA127IK8 mbr-fullscreen">
<!--<iframe width="100%" height="100vh" src="https://www.youtube.com/embed/dfokqepD5NY?controls=0" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen class="cid-qTkA127IK8 vidbacking mbr-fullscreen"></iframe>-->
<video poster="https://pruebasvirality.000webhostapp.com/images/bg/bg-home-mobile.jpg" autoplay muted class="cid-qTkA127IK8 vidbacking mbr-fullscreen" media="(min-width: 990px)">
<source src="" type="video/webm">
<source src="https://pruebasvirality.000webhostapp.com/videos/hero.mp4" type="video/mp4">
</video>
<picture>
<source media="(min-width: 768px) and (max-width: 1030px)" srcset="images/bg/bg-home-mobile.jpg">
<source media="(max-width: 768px)" srcset="https://pruebasvirality.000webhostapp.com/images/bg/bg-home-mobile.jpg">
<img class="mobile-image" src="images/Goodstuff-Office-Mobile-Header.jpg" alt="" />
</picture>
</div>
<div class="mbr-overlay" style="opacity: 0.4; background-color: rgb(35, 35, 35);"></div>
<div class="mouseSlider">
<a href="#ourwork" class="normal"><img src="https://pruebasvirality.000webhostapp.com/images/mouse.png" alt=""></a>
<a href="#ourwork" class="hover"><img src="https://pruebasvirality.000webhostapp.com/images/mouseh.png" alt=""></a>
</div>
</section>
<!-- ALL JS -->
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
<script type="text/javascript" src="https://pruebasvirality.000webhostapp.com/js/bootstrap.js"></script>
<script type="text/javascript" src="https://pruebasvirality.000webhostapp.com/js/owl.carousel.js"></script>
<script type="text/javascript" src="https://pruebasvirality.000webhostapp.com/js/slick.js"></script>
<script type="text/javascript" src="https://pruebasvirality.000webhostapp.com/js/jquery.themepunch.revolution.min.js"></script>
<script type="text/javascript" src="https://pruebasvirality.000webhostapp.com/js/jquery.themepunch.tools.min.js"></script>
<script type="text/javascript" src="https://pruebasvirality.000webhostapp.com/js/theme.js"></script>
<script src="https://pruebasvirality.000webhostapp.com/js/jquery.vidbacking.js" type="text/javascript"></script>
<script type="text/javascript">
$(function(){
$('body').vidbacking({
'masked': true
});
});
</script>
</body>
</html>```
【问题讨论】:
-
使用 CSS 你可以在小屏幕上隐藏视频,看看这个问题 - stackoverflow.com/questions/13847755/…
标签: javascript jquery html css