.gallery{ display: flex; flex-wrap: wrap; justify-content: space-evenly; } .gallery figure{ width: 200px; height: 250px; background-color: var(--backing); transition: transform 0.5s; } .gallery figure:hover:not(.maximised){ transform: rotate(-5deg); } .gallery figure img{ width: 90%; height: 75%; object-fit: fill; margin: 5%; } .gallery figcaption{ text-align: center; padding: 5px; } .maximised{ position: fixed; left: 50%; top: 50%; /* left: 0; */ /* top: 0; */ z-index: 10; height: 90vh !important; width: 80vh !important; transform: translate(-50%, -50%); font-size: 3rem; margin: 0; } .maximised:before{ background-color: var(--backing); content: "click the photo again to close it"; font-size: 2rem; } @media screen and (max-width:1000px){ .maximised{ position: fixed; left: 50%; top: 50%; /* left: 0; */ /* top: 0; */ z-index: 10; height: 90vw !important; width: 80vw !important; transform: translate(-50%, -50%); font-size: 3rem; margin: 0; } .gallery figure{ width: 350px; height: 400px; } }