Last active
May 3, 2023 13:22
-
-
Save macchiitaka/4b2d07843df96aeb47a52f7e2063849a to your computer and use it in GitHub Desktop.
[demo] object-fi
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 lang="ja"> | |
<head> | |
<meta charset="UTF-8" /> | |
<title>object-fit demo</title> | |
<link | |
rel="stylesheet" | |
href="https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.min.css" | |
/> | |
<style> | |
* { | |
font-size: 62.5%; | |
box-sizing: border-box; | |
} | |
.container { | |
width: 100%; | |
} | |
.card-list { | |
display: flex; | |
justify-content: space-between; | |
flex-wrap: wrap; | |
padding: 5px 5px 0 5px; | |
} | |
.card { | |
flex: 1 1 calc((100% - (5px * (3 - 1))) / 3); | |
max-width: calc((100% - (5px * (3 - 1))) / 3); | |
margin-bottom: 5px; | |
padding: 5px; | |
box-shadow: 0 0 1px 0 #000; | |
} | |
.card-contents { | |
height: 100px; | |
display: flex; | |
justify-content: flex-start; | |
align-items: center; | |
} | |
.avatar { | |
height: 80px; | |
width: 80px; | |
border-radius: calc(80px / 2); | |
object-fit: cover; | |
} | |
.section { | |
margin: 0 auto; | |
} | |
.section .text { | |
line-height: 1.4rem; | |
} | |
</style> | |
</head> | |
<body> | |
<div class="container"> | |
<ul class="card-list"> | |
<li class="card"> | |
<div class="card-contents"> | |
<img class="avatar" src="https://placehold.jp/150x300.png" alt="" /> | |
<div class="section"> | |
<p class="text">横長</p> | |
<p class="text">150 x 300 px</p> | |
</div> | |
</div> | |
</li> | |
<li class="card"> | |
<div class="card-contents"> | |
<img class="avatar" src="https://placehold.jp/300x300.png" alt="" /> | |
<div class="section"> | |
<p class="text">正方形</p> | |
<p class="text">300 x 300 px</p> | |
</div> | |
</div> | |
</li> | |
<li class="card"> | |
<div class="card-contents"> | |
<img class="avatar" src="https://placehold.jp/300x150.png" alt="" /> | |
<div class="section"> | |
<p class="text">縦長</p> | |
<p class="text">300 x 150 px</p> | |
</div> | |
</div> | |
</li> | |
</ul> | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment