728x90
CSS : ์ ๋๋ฉ๋์ ๋ง๋ค๊ธฐ : ๐ถ ์ ์ฒด์ ์ธ ์ ๋๋ฉ์ด์ ์์ ~ ๐ + ๋ง์ฐ์ค ์ค๋ฒ ํจ๊ณผ ๐ฑ
์ด๋ฒ ์๊ฐ์๋ CSS ์ค์ต์ผ๋ก ์ ์ฒด์ ์ธ ์ ๋๋ฉ์ด์ ์ ๋ง๋ค์ด๋ณด๊ฒ ์ต๋๋ค~~! ์ค๋์ ํฌ์ธํธ ์์ฑ์ ๋ฐ๋ก~~ transform-style: preserve-3d;์ ๋๋ค!
#1. HTML
๊ตฌ์กฐ๋ฅผ ์๊ณผ ๋ค๊ฐ ๋ฐ๋ก ์๋ค ์๊ฐํ์ฌ ๋งํฌ์ ์ ํด์ฃผ์๋ฉด ๋ฉ๋๋ค.
<div class="hover__wrap">
<div class="hover__updown">
<figure class="front">
<img src="https://user-images.githubusercontent.com/106949433/191177895-3875da4c-06b6-42f8-83cb-b5a7fe7ac88a.jpg" alt="hoverUp ์ด๋ฏธ์ง">
<figcaption>
<h3>Mouse Hover Effect</h3>
<p>๋ง์ฐ์ค ์ฌ๋ฆฌ๋ฉด Up</p>
</figcaption>
</figure>
<figure class="back">
<img src="https://user-images.githubusercontent.com/106949433/191177915-75551c83-9f83-49cc-a1fc-3eff65e014df.jpg" alt="hoverDown ์ด๋ฏธ์ง">
<figcaption>
<h3>Mouse Hover Effect</h3>
<p>๋ง์ฐ์ค ๋ด๋ฆฌ๋ฉด Down</p>
</figcaption>
</figure>
</div>
<div class="hover__leftright">
<figure class="front">
<img src="https://user-images.githubusercontent.com/106949433/191177923-3b338ef2-50ae-48c3-83d1-827f29e39b99.jpg" alt="hoverLeft ์ด๋ฏธ์ง">
<figcaption>
<h3>Mouse Hover Effect</h3>
<p>๋ง์ฐ์ค ์ฌ๋ฆฌ๋ฉด to Right</p>
</figcaption>
</figure>
<figure class="back">
<img src="https://user-images.githubusercontent.com/106949433/191177925-8578bc0b-b09d-4e7c-9b95-21f998b1ae84.jpg" alt="hoverRight ์ด๋ฏธ์ง">
<figcaption>
<h3>Mouse Hover Effect</h3>
<p>๋ง์ฐ์ค ๋ด๋ฆฌ๋ฉด to Left</p>
</figcaption>
</figure>
</div>
</div>
#2. CSS
๋ค์์ CSS ์ฝ๋ ์
๋๋ค!
์ค๋์ ํฌ์ธํธ๋ transform-style: preserve-3d;์ perspective๋ก ์
์ฒด์ ์ธ ํจ๊ณผ๋ฅผ ์ฃผ๊ณ ์ถ์ ๋ ์ฌ์ฉํ๋ ์์ฑ์
๋๋ค.
perspective == ์๊ทผ๊ฐ์ ์ฃผ๋ ์์ฑ
@font-face {
font-family: โLocusSangsangโ;
font-weight: normal;
font-style: normal;
src: url(โhttps://cdn.jsdelivr.net/gh/webfontworld/locus/LocusSangsang.eotโ);
src: url(โhttps://cdn.jsdelivr.net/gh/webfontworld/locus/LocusSangsang.eot?#iefixโ) format(โembedded-opentypeโ),
url(โhttps://cdn.jsdelivr.net/gh/webfontworld/locus/LocusSangsang.woff2โ) format(โwoff2โ),
url(โhttps://cdn.jsdelivr.net/gh/webfontworld/locus/LocusSangsang.woffโ) format(โwoffโ),
url(โhttps://cdn.jsdelivr.net/gh/webfontworld/locus/LocusSangsang.ttfโ) format(โtruetypeโ);
font-display: swap;
}
body {
font-family: โLocusSangsangโ;
background-image: linear-gradient(135deg, #191970 0%, #483088 40%, #0370DB 100%);
height: 100vh;
}
.hover__wrap {
display: flex;
justify-content:center;
align-items: center;
height: 100vh;
}
.hover__wrap > div {
max-width: 400px;
margin: 3%;
position: relative;
/* ์๊ทผ๊ฐ์ ์ฃผ๋ ๊ฒ */
perspective: 1000px;
}
.hover__wrap > div img {
width: 100%;
border: 5px solid #F0F8FF;
box-shadow: 2px 2px 2px 2px rgba(0,0,0,0.2);
box-sizing: border-box;
vertical-align: top;
}
.hover__wrap > div .front {
transition: transform 1s;
backface-visibility: hidden;
transform-style: preserve-3d;
}
.hover__wrap > div .back {
position: absolute;
left: 0;
top: 0;
z-index: -1;
transition: transform 1s;
transform-style: preserve-3d;
}
.hover__wrap > div figcaption {
background: rgba(0,0,0,0.4);
color: #F8F8FF;
padding: 10px;
text-align: center;
line-height: 1.5;
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%) translatez(100px);
width: 60%;
backface-visibility: hidden;
}
.hover__updown {
}
.hover__leftright {
}
/* mouse hover effect */
.hover__updown .front {
transform: rotateX(0deg);
}
.hover__updown:hover .front {
transform: rotateX(180deg);
}
.hover__updown .back {
transform: rotateX(-180deg);
}
.hover__updown:hover .back {
transform: rotateX(0deg);
}
.hover__leftright .front {
transform: rotateY(0deg);
}
.hover__leftright:hover .front {
transform: rotateY(180deg);
}
.hover__leftright .back {
transform: rotateY(-180deg);
}
.hover__leftright:hover .back {
transform: rotateY(0deg);
}
#3. ๊ฒฐ๊ณผ๋ณด๊ธฐ
728x90
'CSS' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[CSS] ์ ๋๋ฉ์ด์ 07 : ์ญ์ฐ์ฐ์ฐ์ฑ ๋์ด๋๋ ๋ฐ์ค (2) | 2022.09.29 |
---|---|
[CSS] ์ ๋๋ฉ์ด์ 06 : ํต!ํต!ํต! ํ ์คํธ (2) | 2022.09.29 |
[CSS] ์ ๋๋ฉ์ด์ 04 : ์จ์ด๋ธ~~์จ์ด๋ธ~~ (6) | 2022.09.19 |
[CSS] ์ ๋๋ฉ์ด์ ์ค์ต : ๊ฑท๊ธฐ ์ ๋๋ฉ์ด์ (from.ํ ๋งคํ ) (4) | 2022.09.08 |
[CSS] CSS ์ ๋๋ฉ์ด์ ์ ๋ํด ์์๋ณด์! (4) | 2022.09.08 |
๋๊ธ