Skip to main content
Inspiring
Oct 26, 2017 7:03 PM UTC
Answered

Centering bootstrap carousel

When this site was last edited 3-4 months ago, I think I remember the images being centered on desktop, with gray bars on either side. I just learned that is no longer the case. Perhaps bootstrap was updated? Or I just have a faulty memory. In any case, I seem to be missing something and would like to center the images horizontally.

2017 Festival Photos | Durham Blues & Brews Festival

Somewhat related, the images are on the small side at 640px wide. A later edit project is to build multiple sizes using srcset. An article referenced on this forum is from 2014. Is it still a recommended method in 2017 (nearly 2018)?

This topic is closed to new replies. Start a new post to keep the conversation going.
BenPleysier
BenPleysierCorrect answer
Community Expert
Oct 26, 2017 8:53 PM UTC

Add either of the following two style rules to the bottom of your CSS

If you want the image to expand full width - no centering required

.carousel img {

     width: 100%;

     height: auto;

}

If you just want to center the image

.carousel img {

     margin: auto;

}

Wappler is the DMXzone-made Dreamweaver replacement and includes the best of their powerful extensions, as well as much more!

5 replies

Nancy OShea
Community Expert
Community Expert
Oct 26, 2017 7:24 PM UTC

What's this for?

<link href="http://getbootstrap.com/examples/carousel/carousel.css" rel="stylesheet">

It's 404 Not Found.  And besides, GetBootstrap is not a CDN.

Bigger images would help a lot.   Try adding this to your custom CSS.

     .carousel-inner img {width:100%; height:100% !important}

And don't forget to fix your code errors.

Showing results for http://www.durhambluesandbrewsfestival.com/photos/2017.htm - Nu Html Checker

Translate
Nancy O'Shea— Product User & Community Expert
larrycfcAuthor
Inspiring
Oct 26, 2017 7:52 PM UTC

I don't know what that getbootstrap link was about. I didn't build the original framework. But I removed it without apparent consequence. I also did the other suggested edits but images are still not centered.

Translate
BenPleysier
Community Expert
BenPleysierCommunity ExpertCorrect answer
Community Expert
Oct 26, 2017 8:53 PM UTC

Add either of the following two style rules to the bottom of your CSS

If you want the image to expand full width - no centering required

.carousel img {

     width: 100%;

     height: auto;

}

If you just want to center the image

.carousel img {

     margin: auto;

}

Translate
Wappler is the DMXzone-made Dreamweaver replacement and includes the best of their powerful extensions, as well as much more!