Created
February 12, 2022 14:16
-
-
Save kpunith8/ad8e7012e21c2fcaebcddae78becbd75 to your computer and use it in GitHub Desktop.
Responsive image grid using flexbox
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Parcel Sandbox</title> | |
<meta charset="UTF-8" /> | |
<meta name="viewport" content="width=device-width, initial-scale=1" /> | |
<link | |
href="https://fonts.googleapis.com/css2?family=Baloo+2:wght@400;500&display=swap" | |
rel="stylesheet" | |
/> | |
<link rel="stylesheet" href="style.css" /> | |
</head> | |
<body> | |
<ul class="gallery"> | |
<li> | |
<img | |
src="https://images.unsplash.com/photo-1596401463492-1ca39cdf7575?ixlib=rb-1.2.1&q=85&fm=jpg&crop=entropy&cs=srgb&ixid=eyJhcHBfaWQiOjE0NTg5fQ" | |
alt="" | |
/> | |
</li> | |
<li> | |
<img | |
src="https://images.unsplash.com/photo-1591756985756-6e231184528b?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1950&q=80" | |
alt="" | |
/> | |
</li> | |
<li> | |
<img | |
src="https://images.unsplash.com/photo-1556195947-316050222289?ixlib=rb-1.2.1&q=85&fm=jpg&crop=entropy&cs=srgb&ixid=eyJhcHBfaWQiOjE0NTg5fQ" | |
alt="" | |
/> | |
</li> | |
<li> | |
<img | |
src="https://images.unsplash.com/photo-1597264121870-2f1b4d43d2f6?ixlib=rb-1.2.1&q=85&fm=jpg&crop=entropy&cs=srgb&ixid=eyJhcHBfaWQiOjE0NTg5fQ" | |
alt="" | |
/> | |
</li> | |
<li> | |
<img | |
src="https://images.unsplash.com/photo-1465566829994-b8da8cae5909?ixlib=rb-1.2.1&q=85&fm=jpg&crop=entropy&cs=srgb&ixid=eyJhcHBfaWQiOjE0NTg5fQ" | |
alt="" | |
/> | |
</li> | |
</ul> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
body { | |
margin: 0.5rem; | |
background-color: #222; | |
} | |
.gallery { | |
list-style: none; | |
padding: 0; | |
margin: 0; | |
display: flex; | |
flex-wrap: wrap; | |
} | |
.gallery li { | |
flex: 1 1 15rem; | |
min-height: 30vh; | |
max-height: calc(50vh - 0.5rem); | |
} | |
img { | |
object-fit: cover; | |
width: 100%; | |
height: 100%; | |
opacity: 0.7; | |
transition: 180ms opacity ease-in-out; | |
} | |
img:hover { | |
opacity: 1; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment