#gallery-container{ background-color: #222023; height: auto; display: flex; flex-direction: row; flex-wrap: wrap; align-items: top; padding-bottom: 3%; } #gallerythumb{ margin-left: 5%; margin-right: 5%; margin-top: 3%; padding: 1%; width: 100%; max-width: 160px; border: 1px dotted white; text-align: center; } #thumbnail{ width: 100%; max-width: 150px; display: block; margin-left: auto; margin-right:auto; }