jquery - 如何在调整窗口大小时在 owl-carousel 中获得 div 高度?
问题描述
我在一个项目中使用owl-Carousel,我需要owlCarousel 内的内容div(topSlidetxt)的高度来调整窗口大小和加载窗口,我已经尝试过了,但还没有得到任何积极的结果。
$('.heroSlide').owlCarousel({
smartSpeed: 1500,
items: 1,
margin:0,
nav:true,
dots:true
});
<div class="heroSlide owl-carousel">
<div class="item">
<div class="row align-items-center">
<div class="col-lg-7">
<div class="topSlideImg">
<img src="assets/images/home-banner-1.jpg" alt="">
</div>
</div>
<div class="col-lg-5">
<div class="topSlidetxt">
<span class="tiTle">South Beach Residences</span>
<h2>Icon to Many, Home to Few</h2>
<a class="linkArrow" href="#">DISCOVER MORE</a>
</div>
</div>
</div>
</div>
</div>
解决方案
您应该使用Owl Carousel 2的API 事件(initialized.owl.carousel,resized.owl.carousel)
使用示例:
$('.heroSlide').owlCarousel({
smartSpeed: 1500,
items: 1,
margin:0,
nav:true,
dots:true,
onInitialized: function () { /* read and use $('.topSlidetxt').height() here */ },
onResized: function () { /* read and use $('.topSlidetxt').height() here */ },
});
推荐阅读
- java - 填充列表视图方法未运行
- edgesdk - susdo apt-get install ./edgesdk-oauth-tool-setup-linux-1.0.0.deb 在 raspbian 上不起作用
- c++ - 通过 shared_ptr 自动调用的非多态派生析构函数
- r - 向 JSON REST API 进行身份验证时如何获取会话令牌(在 R 中)
- javascript - 从 MySQL 获取结果
- c# - 如何使用 NUnit 和 Moq 在 C# 中对需要密封类型作为参数的方法进行单元测试?
- php - 显示所选元素树枝模板
- angular - 提高 Angular 8 中子组件的视觉更新速度
- python - BeautifulSoup 打印分页和名称
- python - 将鼠标移到绘图上时显示的抓取数据