I want my carousel images to be at the center (horizontally), which is not by default. I follow the solution at this topic.
However, using this solution, when the carousel is resized and smaller than the image, the image is cropped instead of scaling as default.
How can I both center my image, but keep it to stretch to the carousel item?
If you want the image to be centred vertically as well as horizontally (i.e. the height of the image is not the height of the carousel), the easiest way is to use flexbox alongside making sure the width and height match the parent.
1. Set some height and width as per your wish in your custom css file. 2. And set img-responsive in your code in the mail HTML Page for carousel items.
To insert multiple jQuery carousels to the same webpage, you need to create each carousel with a unique ID. In Amazing Carousel, Publish dialog, select the option Publish to Folder, then click Browse to select a folder to save the generated files. You need to set up a unique Carousel ID for each carousel.
Now (on Boostrap 3+) it's simply:
.carousel-inner img { margin: auto; }
I assume you have different sized images. I tested this myself, and it works as you describe (always centered, images widths appropriately)
/*CSS*/ div.c-wrapper{ width: 80%; /* for example */ margin: auto; } .carousel-inner > .item > img, .carousel-inner > .item > a > img{ width: 100%; /* use this, or not */ margin: auto; } <!--html--> <div class="c-wrapper"> <div id="carousel-example-generic" class="carousel slide"> <!-- Indicators --> <ol class="carousel-indicators"> <li data-target="#carousel-example-generic" data-slide-to="0" class="active"></li> <li data-target="#carousel-example-generic" data-slide-to="1"></li> <li data-target="#carousel-example-generic" data-slide-to="2"></li> </ol> <!-- Wrapper for slides --> <div class="carousel-inner"> <div class="item active"> <img src="http://placehold.it/600x400"> <div class="carousel-caption"> hello </div> </div> <div class="item"> <img src="http://placehold.it/500x400"> <div class="carousel-caption"> hello </div> </div> <div class="item"> <img src="http://placehold.it/700x400"> <div class="carousel-caption"> hello </div> </div> </div> <!-- Controls --> <a class="left carousel-control" href="#carousel-example-generic" data-slide="prev"> <span class="icon-prev"></span> </a> <a class="right carousel-control" href="#carousel-example-generic" data-slide="next"> <span class="icon-next"></span> </a> </div> </div>
This creates a "jump" due to variable heights... to solve that, try something like this: Select the tallest image of a list
Or use media-query to set your own fixed height.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With