반응형
사이트 만들기 : 이미지 유형3
이번 유형은 hover기능이 들어간 이미지 유형으로, 이미지 하단에서 블러 처리가 된 박스가 올라옴과 동시에 이미지 우측에서 관련 sns로 이동하는 아이콘이 나오도록 제작되었습니다.
이번에는 flex기능이 아닌 grid기능을 사용하여 이미지 위치를 조정하였습니다.
HTML
5개의 article로 태그를 구성하였으며, 첫 번째 이미지는 background로 삽입하여 주석처리 해주었습니다.
<section id="imageType03" class="image__wrap gowun section">
<h2>화려한 색감</h2>
<p>색감이 화려한 사진들을 모아봤습니다. 오래보면 눈이 피로해질 수 있으니 주의하세요!</p>
<div class="image__inner container-fluid">
<article class="image">
<!-- <figure class="image__box">
<img src="img/img_bg03_01.jpg" alt="colorful">
</figure> -->
<div class="image__desc">
<h3>Colorful</h3>
<p>색감이 화려한 사진들을 모아봤습니다. 오래보면 눈이 피로해질 수 있으니 주의하세요!</p>
</div>
<div class="image__sns">
<a href="#" class="link"><span class="ir">페이지이동</span></a>
<a href="#" class="link"><span class="ir">페이지이동</span></a>
<a href="#" class="link"><span class="ir">페이지이동</span></a>
<a href="#" class="link"><span class="ir">페이지이동</span></a>
<a href="#" class="link"><span class="ir">페이지이동</span></a>
</div>
</article>
<article class="image">
<figure class="image__box">
<img src="img/img_bg03_02.jpg" alt="colorful">
</figure>
<div class="image__desc">
<h3>Colorful</h3>
<p>색감이 화려한 사진들을 모아봤습니다. 오래보면 눈이 피로해질 수 있으니 주의하세요!</p>
</div>
<div class="image__sns">
<a href="#" class="link"><span class="ir">페이지이동</span></a>
<a href="#" class="link"><span class="ir">페이지이동</span></a>
</div>
</article>
<article class="image">
<figure class="image__box">
<img src="img/img_bg03_03.jpg" alt="colorful">
</figure>
<div class="image__desc">
<h3>Colorful</h3>
<p>색감이 화려한 사진들을 모아봤습니다. 오래보면 눈이 피로해질 수 있으니 주의하세요!</p>
</div>
<div class="image__sns">
<a href="#" class="link"><span class="ir">페이지이동</span></a>
<a href="#" class="link"><span class="ir">페이지이동</span></a>
</div>
</article>
<article class="image">
<figure class="image__box">
<img src="img/img_bg03_04.jpg" alt="colorful">
</figure>
<div class="image__desc">
<h3>Colorful</h3>
<p>색감이 화려한 사진들을 모아봤습니다. 오래보면 눈이 피로해질 수 있으니 주의하세요!</p>
</div>
<div class="image__sns">
<a href="#" class="link"><span class="ir">페이지이동</span></a>
<a href="#" class="link"><span class="ir">페이지이동</span></a>
</div>
</article>
<article class="image">
<figure class="image__box">
<img src="img/img_bg03_05.jpg" alt="colorful">
</figure>
<div class="image__desc">
<h3>Colorful</h3>
<p>색감이 화려한 사진들을 모아봤습니다. 오래보면 눈이 피로해질 수 있으니 주의하세요!</p>
</div>
<div class="image__sns">
<a href="#" class="link"><span class="ir">페이지이동</span></a>
<a href="#" class="link"><span class="ir">페이지이동</span></a>
</div>
</article>
</div>
</section>
CSS
이번 유형은 grid기법을 사용하였습니다. 우측에서 sns아이콘이 나오도록 하는 방법은, 네이버 사이트의 방법을 참고하였습니다.
figma를 사용하여 5개의 아이콘을 50px 간격으로 배치 후 일괄적으로 png파일로 저장 -> image__sns a 태그에 background로 삽입하고 nth-child()를 사용하여 아래로 50px씩 밀어주어 삽입하였습니다.
/* reset */
img {
width: 100%;
vertical-align: top; //이미지 여백 제거
}
/* ir 효과(이미지 대체 효과 == alt) */
.ir {
display: block;
overflow: hidden;
font-size: 0;
line-height: 0;
text-indent: -9999px;
}
/* common */
.container-fluid {
width: 100%;
padding: 0 100px;
box-sizing: border-box;
}
.section {
padding: 120px 0;
}
.section>h2 {
font-size: 50px;
line-height: 1;
text-align: center;
margin-bottom: 20px;
}
.section>p {
font-size: 22px;
font-weight: 300;
color: #666;
text-align: center;
margin-bottom: 70px;
}
/* imageType */
.image__inner {
display: grid;
grid-template-areas:
"box1 box1 box2 box3"
"box1 box1 box4 box5";
grid-template-columns: 1fr 1fr 1fr 1fr;
grid-template-rows: 1fr 1fr;
grid-gap: 20px;
}
.image {
position: relative;
overflow: hidden;
}
.image__inner .image {}
.image__inner .image:nth-child(1) {
grid-area: box1;
background: url(img/img_bg03_01.jpg) no-repeat;
background-size: cover;
}
.image__inner .image:nth-child(2) {
grid-area: box2;
}
.image__inner .image:nth-child(3) {
grid-area: box3;
}
.image__inner .image:nth-child(4) {
grid-area: box4;
}
.image__inner .image:nth-child(5) {
grid-area: box5;
}
.image__box {}
.image__desc {
position: absolute;
left: 0;
bottom: -100%;
width: 100%;
backdrop-filter: blur(10px);
background: rgba(255, 255, 255, 0.3);
padding: 16px;
box-sizing: border-box;
transition: all 0.4s ease;
}
.image:hover .image__desc {
bottom: 0;
}
.image__desc h3 {
font-size: 20px;
}
.image__desc p {
font-size: 16px;
color: #666;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.image__sns {
position: absolute;
right: -100px;
top: 10px;
transition: all 0.4s ease;
}
.image__sns a {
width: 36px;
height: 36px;
background: #fff;
border-radius: 50%;
display: block;
margin-bottom: 5px;
background: url(img/image_bg03_icon.svg);
}
.image__sns a:nth-child(2) {
background-position: -50px 0;
}
.image__sns a:nth-child(3) {
background-position: -100px 0;
}
.image__sns a:nth-child(4) {
background-position: -150px 0;
}
.image__sns a:nth-child(5) {
background-position: -200px 0;
}
.image:hover .image__sns {
right: 10px;
}
반응형
댓글