본문 바로가기
CSS/Animation

Animation - 움직이는 사진

by SyuMay 2022. 9. 20.
728x90

애니메이션 만들기

애니메이션 : 움직이는 사진

움직이는 사진을 만들어 봅시다.

@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: 500px;
}
.hover__wrap > div img {
  max-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,
.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;
  backface-visibility: hidden;
  transform-style: preserve-3d;
}

.hover__wrap > div figcaption {
  background: rgba(0,0,0,0.4);
  color: #f8f8ff;
  padding: 10px;
  line-height: 1.5;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) translatez(100px);
  width: 60%;
  backface-visibility: hidden;
}

/* mouse hover effect */
.hover__updown .front {
  transform: rotateY(0deg);
}

.hover__updown:hover .front {
  transform: rotateX(180deg);
}

.hover__updown .back {
  transform: rotateX(-180deg);
}
.hover__updown:hover .back {
  transform: rotateX(0deg);
  z-index: 1;
}
.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);
  z-index: 1;
}
    
728x90
반응형

댓글


자바스크립트 사진

JavaScript

자세히보기