.gallery { column-count: 3; column-gap: 1em; } .gallery > div { margin-bottom: 1em; display: block; width: 100%; height: auto; width: 100%; height: auto; position: relative; } .overlay { position: absolute; display: flex; align-items: center; justify-content: center; top: 0; left: 0; height: 100%; width: 100%; opacity: 0; transition: .5s ease; background-color: rgba(0, 0, 0, 0.8); border-radius: 10px; } .gallery > div:hover .overlay { opacity: 1; }