๋ฐ์ํ
๋ง์ฐ์ค ์ค๋ฒ ํจ๊ณผ ๋ง๋ค๊ธฐ๐ญ
์ด๋ฒ ํฌ์คํ ์์๋ ๋ง์ฐ์ค ์ค๋ฒ ํจ๊ณผ๋ฅผ ๋ง๋ค์ด๋ณด๋๋ก ํ๊ฒ ๋ค.
HTML ์ฝ๋
hover__wrap ์์ hover__updown, hover__leftright ๋ ๊ฐ์ div ๋ฐ์ค๊ฐ ๋ค์ด๊ฐ๊ณ ๊ฐ๊ฐ์ div ๋ฐ์ค ์์ figure class="front"์ "back" ์์ ์ด๋ฏธ์ง๊ฐ ๋ค์ด๊ฐ ํํ๋ก Hover์์๋ back, ํ์์์๋ front๊ฐ ๋๋๋ก ๋์ค์ CSS ์ฝ๋ฉ์ ํด์ค๋ค.
์ฝ๋ ํผ์ณ๋ณด๊ธฐ
<div class="hover__wrap">
<div class="hover__updown">
<figure class="front">
<img src="https://oranssy.github.io/coding/animation/img/hoverUp.jpg" alt="">
<figcaption>
<h3>Mouse Hover Effect</h3>
<p>๋ง์ฐ์ค ์ฌ๋ฆฌ๋ฉด Up</p>
</figcaption>
</figure>
<figure class="back">
<img src="https://oranssy.github.io/coding/animation/img/hoverDown.jpg" alt="">
<figcaption>
<h3>Mouse Hover Effect</h3>
<p>๋ง์ฐ์ค ๋ด๋ฆฌ๋ฉด Down</p>
</figcaption>
</figure>
</div>
<div class="hover__leftright">
<figure class="front">
<img src="https://oranssy.github.io/coding/animation/img/hoverLeft.jpg" alt="">
<figcaption>
<h3>Mouse Hover Effect</h3>
<p>๋ง์ฐ์ค ์ฌ๋ฆฌ๋ฉด to Right</p>
</figcaption>
</figure>
<figure class="back">
<img src="https://oranssy.github.io/coding/animation/img/hoverRight.jpg" alt="">
<figcaption>
<h3>Mouse Hover Effect</h3>
<p>๋ง์ฐ์ค ๋ด๋ฆฌ๋ฉด to Left</p>
</figcaption>
</figure>
</div>
</div>
CSS ์ฝ๋
/* ์นํฐํธ */
@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%, #483D8B 40%, #9370DB 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: 10px 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;
}
/* 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);
}
/* mouse hover effect */
.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);
}
๊ฒฐ๊ณผ๋ฌผ
์~์ฑ๐ญ๐ญ
๋ฐ์ํ
'CSS' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[CSS] ์์ง์ด๋ ์ก๋ฉด์ฒด ์ ๋๋ฉ์ด์ ๐ฒ (11) | 2022.09.22 |
---|---|
[CSS] ํตํต ํ๋ ๊ธ์ ํจ๊ณผ๐ฐ (8) | 2022.09.22 |
[CSS] SCSS๋ก ์จ์ด๋ธ ์ ๋๋ฉ์ด์ ๋ง๋ค๊ธฐ๐ (8) | 2022.09.19 |
[CSS] ๊ฑท๋ ํธ๋ฐ ์ ๋๋ฉ์ด์ ๋ง๋ค๊ธฐ๐ (8) | 2022.09.08 |
[CSS] ํ ์คํธ๊ฐ ์์ํ ๊ทธ๋ ค์ง๋ SVG ์ ๋๋ฉ์ด์ (4) | 2022.09.08 |
๋๊ธ