How to extend Twitter Bootstrap image carousel for dynamically sized, centered images

前端 未结 3 1541
春和景丽
春和景丽 2021-02-06 04:05

I\'m trying to extend the default Bootstrap image carousel to support dynamically sized images (500x400 max), centered both horizontally and vertically. Additionally, I\'d like

3条回答
  •  盖世英雄少女心
    2021-02-06 04:51

    You can center horizontally with these rules:

    .carousel-inner { text-align: center; }

    .carousel .item > img { display: inline-block; }

    For vertical aligning you should check out this: http://www.student.oulu.fi/~laurirai/www/css/middle/

    And for keeping the image aspect ratio on resizing you just have to change only the width or only the height of the image not both at a time and it will resize with its original ratio.

提交回复
热议问题