【问题标题】:owl carousel navigation hide猫头鹰轮播导航隐藏
【发布时间】:2016-09-20 07:34:45
【问题描述】:

我使用 owl carousel,我想要幻灯片上方的导航以便轻松导航。现在它们被隐藏或在滑块下方。我不知道如何将它们放在上面。我在CSS 中尝试了 z-index 用于轮播和导航,但没有任何反应。需要帮助,谢谢!

JS

<script>
 $(document).ready(function() {
    $("#owl-demo2").owlCarousel({
        navigation : true, // Show next and prev buttons
        slideSpeed : 300,
        paginationSpeed : 400,
        items : 1,
        itemsDesktop : false,
        itemsDesktopSmall : false,
        itemsTablet: false,
        itemsMobile : false
        });

  });
</script>

CSS

    #owl-demo2 .item img{
    display: block;
    width: 100%;
    height: auto;
    position: relative;
    z-index: 1;
    }
    .owl-theme .owl-controls .owl-buttons div{
    color: #FFF;
    display: inline-block;
    zoom: 1;
    position: fixed;
    z-index: 2000;
    *display: inline;/*IE7 life-saver */
    margin: 90px;
    padding: 20px 0px;
    font-size: 12px;
    -webkit-border-radius: 30px;
    -moz-border-radius: 30px;
    border-radius: 30px;
    background: #869791;
    filter: Alpha(Opacity=50);/*IE7 fix*/
    opacity: 0.5;
}
.owl-buttons {
    position: absolute !important;
    top: -45px !important;
    left: 50% !important;
    transform: translateX(-50%)!important;
}

【问题讨论】:

  • 你能在 JSfiddle 上展示一个工作演示吗?
  • 我可以把我所有的代码放在 jsfiddle 上,但是例子在这里 link 我希望它对你来说已经足够了,谢谢

标签: css owl-carousel


【解决方案1】:

z-index 不会像您希望的那样放置项目。我认为您需要更改这些按钮的位置,而不是设置不同的z-index

这里有一个 z-index 如何工作的示例。根据需要更改 z-index 并检查对齐在这些框上的工作方式:

https://jsfiddle.net/grmcfb7z/

你可以试试这个 CSS 来解决你的问题:

.owl-buttons{
    position: absolute;
    top: -45px;
    left: 50%;
    transform: translateX(-50%);
}

如果它看起来不像您希望的那样,您可能需要对其进行调整。我在你的 cmets 示例上进行了尝试,它对我来说看起来很棒。

更新

在深入研究了确切的问题之后,这里是完整的解决方案:

#owl-demo2 .item img {
    display: block;
    width: 100%;
    height: auto; //we don't need position or z-index property here
}

.owl-theme .owl-controls .owl-buttons div {
    color: #FFF;
    display: inline-block;
    zoom: 1;
    *display: inline; /*IE7 life-saver */
    margin: 10px; //fixed margin to not mess our buttons alignement
    padding: 5px 15px; //smaller padding for better look
    font-size: 12px;
    -webkit-border-radius: 30px;
    -moz-border-radius: 30px;
    border-radius: 30px;
    background: #869791;
    filter: Alpha(Opacity=50); /*IE7 fix*/
    opacity: 0.5;
}

.owl-buttons, .owl-pagination {
    position: absolute !important;
    left: 50% !important;
    transform: translateX(-50%) !important; //here we override our buttons
                                            //positions
}

.owl-buttons {
    top: 0 !important; //nav position
}

.owl-pagination {
    bottom: 0 !important; //pagination position
}

工作 jsfiddle:https://jsfiddle.net/43wo7g98/3/

【讨论】:

  • 我尝试了您的解决方案,但没有任何反应,导航仍在幻灯片下方或下方。我缩小了我的图片,但我也看不到导航
  • 当您覆盖 .owl-buttons 时,它会出现在检查器中吗?也许您只需要使用!important 来强制更改?
  • 是的,它出现了,但我的问题中没有任何反应,我的问题是 owl 的代码,我尝试更改缩放:1 放大:4 我只看到一个按钮上一个按钮。但我没有看到导航(小点)和下一步按钮。这很奇怪,因为我已经在我的索引中放了一个猫头鹰轮播并且已经可以正常工作了
  • 您能从.owl-theme .owl-controls .owl-buttons div 中删除position: fixed; 吗?
  • jsfiddle.net/43wo7g98 我会这样做,但我可以放图片。你可以吗?
猜你喜欢
  • 2021-12-09
  • 1970-01-01
  • 1970-01-01
  • 2016-03-04
  • 1970-01-01
  • 1970-01-01
  • 2018-11-03
  • 1970-01-01
  • 2014-10-09
相关资源
最近更新 更多