ss [CSS]MouseHoverEffect01
본문 바로가기
CSS

[CSS]MouseHoverEffect01

by 꿈나무개발 2022. 9. 20.
728x90

MouseHoverEffect01

오늘은 아래와 MouseHoverEffect를 만들어 보았습니다. 그림에 마우스를 올려보세요~!

HTML

<div class="hover__wrap">
    <div class="hover__updown">
     <figure class="front">
       <img src="http://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, #355C7D 0%, #6C5B7B 40%, #C06C84 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 1.5s;
  backface-visibility: hidden;
  transform-style: preserve-3d;
}

.hover__wrap > div .back {
  position: absolute;
  left: 0;
  top: 0;
  z-index: -1;
  transition: transform 1.5s;
  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.0;
  position: absolute;
  top: 50%;
  left: 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);
}

.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);
}
728x90
반응형

'CSS' 카테고리의 다른 글

[CSS]애니메이션06  (3) 2022.09.22
[CSS]애니메이션05  (2) 2022.09.21
[CSS]애니메이션04  (3) 2022.09.19
[CSS]CSS intro  (5) 2022.09.07
[CSS]SVG intro  (4) 2022.09.07

댓글


HTML
CSS
JAVASCRIPT

JAVASCRIPT

자세히보기
광고 준비중입니다.