# Avatar
<h1>Avatar</h1>
<style>
.container {
display: inline-flex; // flex๋ container๋ผ๋ฆฌ ์์๋๋ก(์ํ)๋ก ์์ด์ง๋ง inline-flex๋ ์ข์ฐ๋ก ์์ธ๋ค.
align-items: center;
}
img {
width: 3rem;
height: 3rem;
object-fit: cover; // ์ฌ์ง์ ๋น์จ์ ์ ์งํ๋ฉด์ ์ฝํ
์ธ ๋ฐ์ค๋ฅผ ๊ฐ๋ ์ฑ์ด๋ค. ๋น์จ์ด ๋ง์ง ์์ผ๋ฉด ์ผ๋ถ๋ ์๋ ค๋๊ฐ
border-radius: 50%; // ๋ชจ์๋ฆฌ ๋ฅ๊ธ๊ฒ
}
h3 {margin-left: 0.5rem;}
</style>
<div class="container">
<img src="์ด๋ฏธ์ง ์ฃผ์" alt="">
<h3>bunny</h3>
</div>
# Thumbnails (opacity)
<style>
img {
width: 100px;
height: 100px;
object-fit: cover;
opacity: 0.8; // ํฌ๋ช
๋ : 0์ ์์ ํฌ๋ช
, 1์ ์์ ๋ถํฌ๋ช
cursor: pointer;
transition: 0.2s; // ์์ฑ๊ฐ์ด ๋ณํ๋๋ฐ ๊ฑธ๋ฆฌ๋ ์๊ฐ
}
img:hover {
opacity: 1;
}
</style>
<div class="container">
<img src="์ด๋ฏธ์ง ์ฃผ์" alt="">
<img src="#" alt="">
<img src="#" alt="">
</div>
# Thumbnail (Scalable)
<h1>Scalcble thumbnails</h1>
<style>
.container {
width: 200px;
height: 200px;
overflow: hidden; // ํ๋๋ ์ด๋ฏธ์ง๊ฐ ์๋์ ํฌ๊ธฐ๋ฅผ ๋์ผ๋ฉด ์๋ผ๋
}
img {
width: 100%;
height: 100%;
object-fit: cover;
transition: 0.2s; // ์์ฑ์ด ๋ณํ๋ element์ transition์ ์ ์ฉํด์ฃผ์ด์ผ ํ๋ค.
}
.container:hover img{
transform: scale(1.1, 1.1); // ํฌ๊ธฐ๊ฐ ๊ฐ๋ก์ถ, ์ธ๋ก์ถ 10%์ฆ๊ฐ
}
</style>
<div class="container">
<img src="#" alt="">
</div>
# hoverable Overlay Thumbnails
<style>
.container {
width: 200px;
height: 200px;
cursor: pointer;
position: relative;
}
img {
width: 100%;
height: 100%;
object-fit: cover;
}
.item {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
background-color: rgba(0 0 0 / 0.5);
display: flex;
justify-content: center;
align-items: center;
color: #fff;
opacity: 0;
transition: 0.2s; // display: none์ ์ฌ์ฉํ๋ฉด ๋ถ๋๋ฌ์ด ํจ๊ณผ๋ฅผ ๋ผ ์ ์๋ค.(์ค๊ฐ๊ฐ์ด ์์ด์ผ ํจ)
}
.container:hover .item {
opacity: 1;
}
</style>
<div class="container">
<div class="item">🦆🦆🦆</div>
<img src="#" alt="">
</div> -->
# Main image
<style>
.container {
height: 20rem;
background-color: #ddd;
background-image: linear-gradient(to right, #f60, #f00);
position: relative;
}
.item {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0; // item์ ํฌ๊ธฐ๋ฅผ width๋ height์ ์ ์ ์์ด container์ ๋ง์ถค
display: flex;
justify-content: center;
align-items: center;
}
</style>
<div class="container">
<div class="item">
<h1>Heading</h1>
</div>
</div>
# reponsive image
- ์ด๋ฏธ์ง๋ ๊ฐ๋ก, ์ธ๋ก ๋ ์ค ํ๋๋ง ์ค์ ํด๋ ์ฌ์ง ๋น์จ์ ๋ง์ถ์ด ์๋์ผ๋ก ์ถ๋ ฅ๋๋ค.
+ ๋น์จ์ด ๋ค๋ฅธ ์ฌ์ง์ ๋์์ ์ถ๋ ฅํ ๋
<h1>Q. Responsive</h1>
<style>
.container {
display: flex;
align-items: flex-start; // stretch๊ฐ ๊ธฐ๋ณธํ์ด๋ฏ๋ก
}
img {
width: 50%;
height: auto;
}
</style>
<div class="container">
<img src="#" alt="">
<img src="#" alt="">
</div>
# ํ๋์ค๋ฅผ ํ์ฉํ ๊ทธ๋ฆฌ๋
<style>
.container {
display: flex; // item 3๊ฐ๋ฅผ ์ค๋ฐ๊ฟ์์ด ์ผ๋ ฌ๋ก ๋ฐฐ์ด
/* gap: 1rem; */
}
.item {
width: 33.33333%;
}
img {
width: 100%;
padding: 0.5rem;
box-sizing: border-box;
}
</style>
<div class="container">
<div class="item">
<img src="์ด๋ฏธ์ง ์ฃผ์" alt="">
<img src="#" alt="">
<img src="#" alt="">
</div>
<div class="item">
<img src="#" alt="">
<img src="#" alt="">
<img src="#" alt="">
</div>
<div class="item">
<img src="#" alt="">
<img src="#" alt="">
<img src="#" alt="">
</div>
</div>
'HTML&CSS' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
CSS 11์ฐจ์ (0) | 2022.11.20 |
---|---|
CSS 10์ฐจ์ (0) | 2022.11.16 |
CSS 8์ฐจ์ (0) | 2022.11.11 |
CSS 7์ฐจ์ (0) | 2022.11.07 |
CSS 6์ฐจ์ (0) | 2022.11.06 |
๋๊ธ