Benedikt Winckler Benedikt Winckler - 13 days ago 4x
CSS Question

Why can't I use flex box in this div to center it both horizontally and vertically?

I am trying to build a completely centered slider with images in different sizes.
I used flexbox to center the div of the slider and now I have to center the images inside it. I tried to use flexbox in there as well but it didn't seem to work for me.

I uploaded it here so that you can see whats wrong.


It's because your container is too big. Your container should be as big as your images OR you should put display:flex; justify-content:center; align-items: center; on the container that contains the images.

Either way, your container can't have a width of 100% or the inside will never be aligned to the center...