【发布时间】:2018-03-30 03:05:45
【问题描述】:
您好,我有一个基于 Shopify 的网站,我想要一个漂亮的背景视频,所以我在 slidshow.liquid 文件上编写了代码,背景视频在正常大小的浏览器上可以正常工作,但是当它在移动设备上查看时,我看不到背景视频,而是留下了很多空白。
核心代码如下:
{% if section.settings.displayBGVOrNot == true %}
<div id="videoSection" class="background-video">
<video playinline autoplay muted loop id="bgvid">
<source src="{{ section.settings.background_video_url }}" type="video/webm">
</video>
</div>
{% endif %}
{% javascript %}
$(document).ready(function() {
var viewPointHeight = $(window).height();
var viewPointWeight = $(window).width();
$('.background-video').css('height', viewPointHeight - 40 + 'px');
$('.background-video').css('width', viewPointWeight + 'px');
});
$(window).resize($.debounce(250,
function() {
var viewPointHeight = $(window).height();
var viewPointWeight = $(window).width();
$('.background-video').css('height', viewPointHeight - 40 + 'px');
$('.background-video').css('width', viewPointWeight + 'px');
})
);
{% endjavascript %}
#videoSection {
position: relative;
overflow: hidden;
}
video#bgvid {
position: relative;
width: 100%;
z-index: 0;
background-size: cover;
}
@media screen and (max-device-width: 800px) {
html {
background: url(polina.jpg) #000 no-repeat center center fixed;
}
#bgvid {
display: none;
}
}
网站是https://opusion.com/,您可以在移动设备上查看。
谢谢!
【问题讨论】:
标签: jquery html css responsive-design shopify