javascript 猫头鹰轮播全屏不起作用
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/29647802/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Owl carousel full screen doesn't work
提问by Lukas
I am trying to make owl carousel slider full screen for my site. This is what I need, feel free to resize Your browser
我正在尝试为我的网站制作 owl carousel 滑块全屏。这就是我需要的,随时调整浏览器的大小
And this is what I have,
这就是我所拥有的
$(document).ready(function() {
// carousel setup
$(".owl-carousel").owlCarousel({
navigation : false,
slideSpeed : 300,
paginationSpeed : 400,
singleItem: true,
autoHeight: true,
afterMove: top_align,
});
function top_align() {
$(window).scrollTop(0);
console.log('move');
}
});
is there any solution to fix it?
有什么解决方案可以解决吗?
Thx
谢谢
采纳答案by pqdong
回答by Xavier Castaneda
When using % for heights, you have to work your way down the DOM chain to your child element for the height to apply.
当使用 % 作为高度时,你必须沿着 DOM 链向下工作到你的子元素以应用高度。
Another option is to take advantage of vh units. 100vh = 100% of the window height.
另一种选择是利用 vh 单位。100vh = 窗口高度的 100%。
Just add 100vh to .owl-item and your div item.
只需将 100vh 添加到 .owl-item 和您的 div 项目。
.owl-item, .item {
height: 100vh;
}
A vh
unit is defined as:
一个vh
单位定义为:
Equal to 1% of the height of the viewport's initial containing block.
等于视口初始包含块高度的 1%。