Adarsh Sosale
Adarsh Sosale

Reputation: 75

Carousel/slider with icons and divs instead of images

I am working on a project where icons need to be dynamically displayed based on the user's selection. These icons are basically glyphs and have a 2-word title beneath them. In short, there's an

<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>

I want these icons and their respective divs to be displayed as a slider/carousel. I tried using owl carousel and replacing img with this. Didn't work. I'm using bootstrap and Jquery. I tried coming up with a custom solution, but was unsuccessful.

Upvotes: 0

Views: 3281

Answers (1)

ɐsɹǝʌ ǝɔıʌ
ɐsɹǝʌ ǝɔıʌ

Reputation: 4512

Not sure if this is what you're looking for

<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

Upvotes: 2

Related Questions