Skip to content

Instantly share code, notes, and snippets.

@nicubarbaros
Created April 25, 2023 18:38
Show Gist options
  • Save nicubarbaros/81e2f18bcd5a0a947f7cfd81fcd7fd65 to your computer and use it in GitHub Desktop.
Save nicubarbaros/81e2f18bcd5a0a947f7cfd81fcd7fd65 to your computer and use it in GitHub Desktop.
.placement-container {
display: grid;
width: 100vw;
height: 100vh;
place-items: center;
}
.grid-container {
display: grid;
grid-template-columns: repeat(2, 1fr);
width: 90%;
gap: 2%;
}
.grid-container--element {
cursor: pointer;
border-radius: 10px;
overflow: hidden;
position: relative;
}
.grid-container--element img {
width: 100%;
height: 100%;
object-fit: cover;
aspect-ratio: 1/1;
}
.grid-container--element:before {
content: "";
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: linear-gradient(
to bottom,
rgba(255, 147, 173, 0) 0%,
rgba(255, 147, 173, 0.6) 100%
);
transition: opacity 0.3s cubic-bezier(0.215, 0.61, 0.3555, 1);
opacity: 0;
}
.grid-container--element:hover:before {
opacity: 1;
}
<!DOCTYPE html>
<html lang="en">
<head>
<title>This is the title of the webpage!</title>
<link rel="stylesheet" href="main.css" />
</head>
<body>
<div class="placement-container">
<div class="grid-container">
<div class="grid-container--element">
<img
src="https://images.unsplash.com/photo-1448301858776-07f780e9c9da?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=2370&q=80"
/>
</div>
<div class="grid-container--element">
<img
src="https://images.unsplash.com/photo-1572294683080-aeb1dea49514?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=2370&q=80"
/>
</div>
<div class="grid-container--element">
<img
src="https://images.unsplash.com/photo-1542318099375-c20b8c991bbe?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=2370&q=80"
/>
</div>
<div class="grid-container--element">
<img
src="https://images.unsplash.com/photo-1572294373686-d248cba28594?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwcm9maWxlLXBhZ2V8Mnx8fGVufDB8fHx8&auto=format&fit=crop&w=800&q=60"
/>
</div>
</div>
</div>
</body>
</html>
@nicubarbaros
Copy link
Author

Screenshot 2023-04-25 at 21 39 03

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment