猫头鹰走马灯的外部箭头导航

8
我正在尝试在作品集网站中使用带有延迟加载图像的Owl Carousel,但是在定位导航按钮时遇到了问题。理想情况下,我想将这些按钮添加到轮播器的外部,并将其定位在图像的中心位置。我已经看过一些操作示例,但是无法理解它。请问有人能够帮忙吗?
我在这里添加了一个JSfiddle:http://jsfiddle.net/iameuanmackay/448htq9b/ 我使用的代码是:
<div class="col-xs-8 col-xs-push-2 col-md-push-3 col-lg-6 col-lg-push-3" style="padding-left:45px">
    <div class="owl-demo">
        <img class="owl-lazy" data-src="http://megmackayphoto.com/Beta/lib/img/full/people_02.jpg" alt="">
        <img class="owl-lazy" data-src="http://megmackayphoto.com/Beta/lib/img/full/people_02.jpg" alt="">
        <img class="owl-lazy" data-src="http://megmackayphoto.com/Beta/lib/img/full/people_03.jpg" alt="">
        <img class="owl-lazy" data-src="http://megmackayphoto.com/Beta/lib/img/full/people_04.jpg" alt="">
        <img class="owl-lazy" data-src="http://megmackayphoto.com/Beta/lib/img/full/people_05.jpg" alt="">
    </div>
</div>

CSS:

#owl-demo .item {
  display: block;
  padding: 30px 0px;
  margin: 5px;
  color: #FFF;
  -webkit-border-radius: 3px;
  -moz-border-radius: 3px;
  border-radius: 3px;
  text-align: center;
}
.owl-theme .owl-controls {
  margin-top: 10px;
  text-align: center;
}
/* Styling Next and Prev buttons */
.owl-theme .owl-controls .owl-buttons div {
  color: #FFF;
  display: inline-block;
  zoom: 1;
  *display: inline;
  /*IE7 life-saver */
  margin: 5px;
  padding: 3px 10px;
  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;
}

以下是相关的js代码:

jQuery(document).ready(function ($) {
  $('.owl-demo').owlCarousel({
    items: 1,
    nav: true,
    navigationText: [
        "<i class='icon-chevron-left icon-white'><</i>",
        "<i class='icon-chevron-right icon-white'>></i>"],
    lazyLoad: true,
    loop: true,
    margin: 10
  });
});

任何对我做错的指导都将不胜感激。
提前致谢。
3个回答

13

$(document).ready(function() {
  $(".slider1").owlCarousel({
    margin: 15,
    items:1,
    responsiveClass:true,
    nav: true,
    autoHeight: true,
    loop:false,
    navText: [
      "<i class='fa fa-chevron-left'></i>",
      "<i class='fa fa-chevron-right'></i>"
    ],
    loop:true,
    responsiveClass:true,
    responsive:{
        0:{
            items:1
        }
    }
  }); 
});
@import url(http://owlcarousel2.github.io/OwlCarousel2/assets/owlcarousel/assets/owl.carousel.min.css);
@import url(https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css);
@import url(http://maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css);

.owl-carousel {
 margin: 0;
}

.owl-carousel .owl-nav [class*=owl-] {
 background: rgba(0, 0, 0, 0.5);
 color: rgba(255, 255, 255, 0.9);
 font-size: 11px;
 width: 30px;
 height: 30px;
 line-height: 30px;
 border-radius: 0;
 text-align: center;
}

.owl-carousel .owl-nav [class*=owl-]:hover {
 background: rgba(0, 0, 0, 0.9);
 color: #FFF;
}

.owl-carousel .owl-prev,
.owl-carousel .owl-next {
 position: absolute;
 top: 10px;
 height: 30px;
 margin: auto !important;
}

.owl-carousel .owl-prev {
 right: 45px;
}

.owl-carousel .owl-next {
 right: 10px;
}

.owl-carousel .owl-dots {
 display: none !important;
}
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>Owl Carousel - Single Slider</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<div class="container">
    <div class="row">
      <div class="col-xs-12">
        <div class="owl-carousel slider1">
          <figure>
            <img src="http://i.imgur.com/RGGxODF.jpg" class="img-responsive" alt="...">
          </figure>
          <figure>
            <img src="http://i.imgur.com/RGGxODF.jpg" class="img-responsive" alt="...">
          </figure>
          <figure>
            <img src="http://i.imgur.com/RGGxODF.jpg" class="img-responsive" alt="...">
          </figure>
          <figure>
            <img src="http://i.imgur.com/RGGxODF.jpg" class="img-responsive" alt="...">
          </figure>
          <figure>
            <img src="http://i.imgur.com/RGGxODF.jpg" class="img-responsive" alt="...">
          </figure>  
        </div>
      </div>
  </div>
</div>

<script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.0/js/bootstrap.min.js"></script>
<script src="http://owlcarousel2.github.io/OwlCarousel2/assets/owlcarousel/owl.carousel.js" type="text/javascript"></script>
</body>
</html>


1
欢迎来到 SO。我建议您通过阅读“最小、完整和可验证的示例”(Minimal, Complete and verifiable example,简称 MCVE)来改进您的示例。 - IlGala
对于旧版本,只需使用.owl-theme .owl-controls - Shaiju T

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

演示链接:http://codepen.io/OwlFonk/pen/qhgjb/


7
针对 owl-carousel-2,将 navigationText 改为 navText - webdevanuj
同时将“导航”更改为“nav”。 - sorinu26

0

导航文本:["", ""]

完整代码如下:

var owl1 = $("#main-demo");
owl1.owlCarousel({
    navigation: true, // Show next and prev buttons
    slideSpeed: 300,
    pagination:false,
    singleItem: true, transitionStyle: "fade",
    navigationText: ["", ""]
});// Custom Navigation Events

owl1.trigger('owl.play', 4500);

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接