旋转木马/滑块与图标和div而不是图像

时间:2015-04-21 06:33:14

标签: javascript jquery css twitter-bootstrap

我正在开发一个项目,根据用户的选择,需要动态显示图标。这些图标基本上都是字形,下面有一个2字的标题。简而言之,那就是

<div class="col-md-9">                   //main container to hold the slider
  <i class="some-icon-name"></i>            
  <div class="col-md-3">
    Some title
  </div>  
  --
  <i class="some-icon-name"></i>
  <div class="col-md-3">
    Some title
  </div>
  --
</div>

我希望这些图标及其各自的div显示为滑块/轮播。我尝试使用owl carousel并用此替换img。没有工作。我使用bootstrap和Jquery。我尝试了一个自定义解决方案,但没有成功。

1 个答案:

答案 0 :(得分:2)

不确定这是否是您正在寻找的

<div id="wrapper">
<div id="myCarousel" class="carousel slide" data-ride="carousel">
  <!-- Indicators -->
  <ol class="carousel-indicators">
    <li data-target="#myCarousel" data-slide-to="0" class="active"></li>
    <li data-target="#myCarousel" data-slide-to="1"></li>
    <li data-target="#myCarousel" data-slide-to="2"></li>
    <li data-target="#myCarousel" data-slide-to="3"></li>
  </ol>

  <!-- Wrapper for slides -->
  <div class="carousel-inner" role="listbox">
    <div class="item active">
      <span class="glyphicon glyphicon-search" aria-hidden="true"></span>
      <span class="caption">Search</span>
    </div>

    <div class="item">
      <span class="glyphicon glyphicon-star" aria-hidden="true"></span>
      <span class="caption">Star</span>
    </div>

    <div class="item">
      <span class="glyphicon glyphicon-ice-lolly" aria-hidden="true"></span>
      <span class="caption">Ice lolly</span>
    </div>

    <div class="item">
      <span class="glyphicon glyphicon-apple" aria-hidden="true"></span>
      <span class="caption">Apple</span>
    </div>
  </div>

  <!-- Left and right controls -->
  <a class="left carousel-control" href="#myCarousel" role="button" data-slide="prev">
    <span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
    <span class="sr-only">Previous</span>
  </a>
  <a class="right carousel-control" href="#myCarousel" role="button" data-slide="next">
    <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
    <span class="sr-only">Next</span>
  </a>
</div>
</div>

<强> CSS

#wrapper {
  position:relative; 
  overflow:hidden; 
  width:50%
  height: 100%; 
  margin:0px auto; 
  padding:0; 
  background-color:Grey;
  margin-left:150px;
  margin-right:150px
}

.glyphicon {
    font-size: 100px;
}

.caption {
    display: block;
}

DEMO