I\'m having a problem centering an element that has the attribute position
set to absolute
.
Does anyone know why the images are not centered?
Just use display: flex
and justify-content: center
on the parent element
body {
text-align: center;
}
#slideshowWrapper {
margin-top: 50px;
text-align: center;
}
ul#slideshow {
list-style: none;
position: relative;
margin: auto;
display: flex;
justify-content: center;
}
ul#slideshow li {
position: absolute;
}
ul#slideshow li img {
border: 1px solid #ccc;
padding: 4px;
height: 100px;
}
You can find this solution in JSFIDDLE