最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Create bootstrap carousel with captions instead of dots - Stack Overflow

programmeradmin5浏览0评论

Standard bootstrap carousel can contains dots to change slides (example on bootstrap page).

However, I recently read Why Users Aren't Clicking Your Home Page Carousel which proposed using captions instead of dots like below:

Is this option possible in bootstrap? If so, how can I do so?

Standard bootstrap carousel can contains dots to change slides (example on bootstrap page).

However, I recently read Why Users Aren't Clicking Your Home Page Carousel which proposed using captions instead of dots like below:

Is this option possible in bootstrap? If so, how can I do so?

Share Improve this question edited May 7, 2014 at 13:10 KyleMit 30.1k72 gold badges506 silver badges698 bronze badges asked May 7, 2014 at 11:42 Piotr StappPiotr Stapp 19.8k11 gold badges71 silver badges116 bronze badges 2
  • To answer your question, yes it is possible, but you'll have to write some code to do it. What have you tried? – KyleMit Commented May 7, 2014 at 12:03
  • @KyleMit the question should be: were should I make changes to have such effect. I didn't write any code because I don't know where should I start. I don't want to change bootstrap.js – Piotr Stapp Commented May 7, 2014 at 12:10
Add a ment  | 

1 Answer 1

Reset to default 14

You can doing this by just overriding the styles on the carousel-indicators list items.

Here's a typical indicators section:

<ul class="carousel-indicators">
  <li data-target="#myCarousel" data-slide-to="0" class="active">One</li>
  <li data-target="#myCarousel" data-slide-to="1">Two</li>
  <li data-target="#myCarousel" data-slide-to="2">Three</li>
</ul>

You'll want to override some of the default Bootstrap styles:

Convert the display from dots to rectangles by adding a width and height and removing the border-radius:

Then get the text back by removing the negative text-indent added by Bootstrap:

Finally, add your own background and border and style however else you like.
The full styling should look like this:

.carousel-indicators > li,
.carousel-indicators > li.active{
    width: 100px;
    height: 25px;
    border-radius: 0;
    border: solid 1px grey;
    background: lightgrey;
    text-indent: 0;
}
.carousel-indicators > li.active {
    background: white;
}

Working Demo in Fiddle


You could even wrap the entire bit of CSS inside of a media query so that when screen size became limited, you defaulted back to the dots instead of awkwardly stacking the list items:

@media screen and (min-width: 550px) {
    /* Wrap CSS Here */
}

Responsive Demo in Fiddle

发布评论

评论列表(0)

  1. 暂无评论