2

我使用 owl carousel 插件,找不到如何让导航垂直对齐中心,带有选项 autoHeight。

http://codepen.io/anon/pen/jJAHL

我试过像下面一样,但它只得到最后一个高度。

$(this_gallery).owlCarousel({
  singleItem: true,
  autoHeight : true,
  navigation:true,
  stopOnHover : true,
  afterAction: function() {
    var center_height = $(this_gallery).find('.owl-wrapper-outer').height();
    console.log(center_height);
  }
});
4

7 回答 7

3

而不是top position在像素中给出它,percentage如下所示:

.owl-theme .owl-controls .owl-buttons .owl-prev {
    left: -45px;
    top: 45%;
}
于 2014-07-23T07:45:16.903 回答
2

也许有点晚了,但这对我来说效果很好,可能会帮助其他人:

#photos .owl-nav{
    position: absolute;
    top: 45%;
    width: 100%;
}
#photos .owl-prev{
    float:left;
 }
#photos .owl-next{
    float:right;
}
于 2017-03-16T09:10:58.550 回答
1

您可以将这些代码添加到样式表中。这些代码将使您的猫头鹰轮播导航居中。希望你会喜欢。

    .owl-nav .owl-next, .owl-nav .owl-prev {
        position: absolute;
        top: 48%;
        transform: translateY(-50%);
        -webkit-transform: translateY(-50%);
    }
    .owl-nav .owl-next {
        right: 0;
        display: flex;
        margin-right: 2%;
        font-size: 25px !important;
    }
    .owl-nav .owl-prev{
        left: 0;
        display: flex;
        margin-left: 2%;
        font-size: 25px !important;
    }
于 2020-04-05T14:21:32.887 回答
0

更改上一个和下一个按钮的 css

.owl-theme .owl-controls .owl-buttons .owl-next,.owl-theme .owl-controls .owl-buttons .owl-prev
 {
    top:40%;
 }
于 2014-07-23T07:57:31.433 回答
0

你可以试试这个:

.owl-nav div {
      position: absolute;
      left: -50px;
      top: 45%;
      color: $theme-color;
      display: table;
      &.owl-next {
        left: auto;
        right: -50px;
      }
    }
于 2019-11-11T06:31:37.513 回答
0
.owl-prev, .owl-next
{
    position: absolute;
}
.owl-prev
{
    left: -60px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 40px !important;
    background-color: transparent !important;
    outline: none !important;
}
.owl-next
{
    right: -60px;
    top: 50%;`enter code here`
    transform: translateY(-50%);
    font-size: 40px !important;
    background-color: transparent !important;
    outline: none !important;
}
于 2020-08-12T15:42:49.777 回答
0
body .owl-nav {
  position: absolute;
  top: calc(50% - 14px);
  width: 104%;
  left: -47px;
  display: flex;
  justify-content: space-between;
}

button.owl-prev>span,
button.owl-next>span {
  background: #efefef;
  font-size: 49px;
  border-radius: 50%;
  padding: 7px 7px 14px 7px;
  width: 50px;
  height: 50px;
  position: absolute;
  display: flex;
  justify-content: center;
  align-items: center;
  color: #fff;
  font-weight: 600;
}
于 2021-03-12T18:14:47.080 回答