简体   繁体   English

如何在不同页面上使用多个猫头鹰轮播来更改按钮的位置

[英]How to change positions of buttons using multiple owl carousels on different pages

I have successfully managed to add 2 owl carousels on my shopify site and these are both working fine. 我已经成功地在shopify网站上添加了2个猫头鹰轮播,而且它们都工作正常。 The only issue I have is that on my 2nd page the navigation buttons for the carousel are being picked up from the following style (the position I need them for the first carousel): 我唯一的问题是,在第二页上,轮播的导航按钮是从以下样式(第一个轮播需要的位置)中拾取的:

.owl-theme .owl-controls .owl-buttons .owl-prev{
  left: -45px;
  top: 40%; 
}

.owl-theme .owl-controls .owl-buttons .owl-next{
  right: -45px;
  top: 40%;
}

And I am not sure what I need to do in order to display the navigation in a different position as currently I have my carousel but my navigation is showing in another position at the top of the page. 而且我不确定要在其他位置显示导航的方法,因为我现在有轮播,但是导航显示在页面顶部的其他位置。 If somebody could please advise on what I need to do to change this. 如果有人可以提出建议,我应该做些什么来改变这一点。

The following is the javascript code (same on both pages): 以下是javascript代码(两个页面上都相同):

<script>


    $(document).ready(function () {
    var carousel = $("#owl-demo");
  carousel.owlCarousel({
    items: 3,
    margin:10,
    navigation:true,
    autoHeight : true,
    autoPlay : 3000,
    navigationText: [
      "<i class='icon-chevron-left icon-white'><</i>",
      "<i class='icon-chevron-right icon-white'>></i>"
      ],
  });
});
  </script>

and the following is the HTML: 以下是HTML:

<div class="wrapper-with-margin">
<div id="owl-demo" class="owl-carousel-design">
<div><img src="slider1.jpg" alt="" /></div>
<div><img src="slider2.jpg" alt="" /></div>
<div><img src="slider3.jpg" alt="" /></div>
</div>
</div>

Would really appreciate it if somebody could advise on how I can fix this, as I would like to add more carousels to the other pages but need to fix this first. 如果有人可以就如何解决此问题提供建议,我将非常感激,因为我想在其他页面上添加更多轮播,但需要先解决此问题。

Thanks in advance. 提前致谢。

Is it possible to add a modifier class on one of these sliders? 是否可以在其中一个滑块上添加修饰符类?

You can even do it if you're calling the same snippet from both, just make sure that, for example, if the second page is using a template called page.special.liquid then... 如果您要从两者调用相同的代码段,甚至可以执行此操作,只需确保例如,如果第二页正在使用名为page.special.liquid的模板,则...

<div class="wrapper-with-margin">
  <div id="owl-demo" class="owl-carousel-design {% if template contains 'special' %}owl-special{% endif %}">
    <div><img src="slider1.jpg" alt="" /></div>
    <div><img src="slider2.jpg" alt="" /></div>
    <div><img src="slider3.jpg" alt="" /></div>
  </div>
</div>

And then on your CSS, below your original rules for your 1st page carousel, modify the values as per your needs: 然后在CSS上,在第一页轮播的原始规则下,根据需要修改值:

.owl-special .owl-theme .owl-controls .owl-buttons .owl-prev{
  left: -25px;
  top: 20%; 
}

.owl-special .owl-theme .owl-controls .owl-buttons .owl-next{
  right: -25px;
  top: 20%;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM