CSS旋转图像上的简单HTML文本

时间:2017-06-15 18:14:34

标签: html css css3

目前我正在使用以下滑块。我需要像其他滑块一样在图像上添加文字:https://codepen.io/suez/pen/vEZMoa

以下是我想在其图片上添加文字的滑块代码:

body { margin: 0; background: #121; } 
figure { 
  margin: 0;
  position: relative;
  perspective: 1800px;
  transform-style: preserve-3d;
  max-width: 1000px; 
  padding-bottom: 56.25%; 
}

body::before,
body::after { 
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  background: url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/4273/autumn-face.jpg) no-repeat left top;
  background-size: 100%;
}
body::after { 
  background: url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/4273/julia.jpg) no-repeat left top;
  background-size: 100%;
  animation-name: swapbkg;
  animation-duration: 4s;
  animation-iteration-count: infinite;
}

figure img { 
  top: 0;
  left: 0;
  position: absolute;
  width: 100%;
  _opacity: 0
}

figure.anim img.first {
  animation-name: rotateus2;
  animation-duration: 4s;
  animation-iteration-count: infinite;
} 
figure.anim img.second { 
  animation-name: rotateus;
  animation-duration: 4s;
  animation-iteration-count: infinite;
}

@keyframes rotateus {
  0%, 80%, 100%  {
    transform: rotateY(0deg);
  }
  30%, 50% {
    transform: rotateY(180deg);
  }
} 
@keyframes rotateus2 {
  0%, 80%, 100%  {
    transform: rotateY(-180deg) translateZ(1px);
  }
  30%, 50% {
    transform: rotateY(0deg) translateZ(1px); 
  }  
}
@keyframes swapbkg {
  0%, 39% {
    z-index: -1;
  }
  40%, 80% {
    z-index: -2;
  }
} 

figure img:nth-child(1), figure img:nth-child(11) { 
  clip: rect(0px, 100px, 840px, 0px);
  transform-origin: 50px 0px;
}
figure img:nth-child(2), figure img:nth-child(12) {
  clip: rect(0px, 200px, 840px, 100px);
  transform-origin: 150px 0px;
  animation-delay: 100ms;
}
figure img:nth-child(3), figure img:nth-child(13) {
  clip: rect(0px, 300px, 840px, 200px);
  transform-origin: 250px 0px;
  animation-delay: 200ms;  
}
figure img:nth-child(4), figure img:nth-child(14) {
  clip: rect(0px, 400px, 840px, 300px);
  transform-origin: 350px 0px;
  animation-delay: 300ms; 
}
figure img:nth-child(5), figure img:nth-child(15) {
  clip: rect(0px, 500px, 840px, 400px);
  transform-origin: 450px 0px;
  animation-delay: 400ms;
}
figure img:nth-child(6), figure img:nth-child(16) {
  clip: rect(0px, 600px, 840px, 500px);
  transform-origin: 550px 0px;
  animation-delay: 500ms; 
}
figure img:nth-child(7), figure img:nth-child(17) {
  clip: rect(0px, 700px, 840px, 600px);
  transform-origin: 650px 0px;
  animation-delay: 600ms;
}
figure img:nth-child(8), figure img:nth-child(18) {
  clip: rect(0px, 800px, 840px, 700px);
  transform-origin: 750px 0px;
  animation-delay: 700ms;
}
figure img:nth-child(9), figure img:nth-child(19) {
  clip: rect(0px, 900px, 840px, 800px);
  transform-origin: 850px 0px;
  animation-delay: 800ms; 
}
figure img:nth-child(10), figure img:nth-child(20) {
  clip: rect(0px, 1000px, 840px, 900px);
  transform-origin: 950px 0px;
  animation-delay: 900ms;  
}
<figure id=blinds-window class="anim">
<img src=https://s3-us-west-2.amazonaws.com/s.cdpn.io/4273/autumn-face.jpg alt class=first>
<img src=https://s3-us-west-2.amazonaws.com/s.cdpn.io/4273/autumn-face.jpg alt class=first>
<img src=https://s3-us-west-2.amazonaws.com/s.cdpn.io/4273/autumn-face.jpg alt class=first>
<img src=https://s3-us-west-2.amazonaws.com/s.cdpn.io/4273/autumn-face.jpg alt class=first>
<img src=https://s3-us-west-2.amazonaws.com/s.cdpn.io/4273/autumn-face.jpg alt class=first>
<img src=https://s3-us-west-2.amazonaws.com/s.cdpn.io/4273/autumn-face.jpg alt class=first>
<img src=https://s3-us-west-2.amazonaws.com/s.cdpn.io/4273/autumn-face.jpg alt class=first>
<img src=https://s3-us-west-2.amazonaws.com/s.cdpn.io/4273/autumn-face.jpg alt class=first>
<img src=https://s3-us-west-2.amazonaws.com/s.cdpn.io/4273/autumn-face.jpg alt class=first>
<img src=https://s3-us-west-2.amazonaws.com/s.cdpn.io/4273/autumn-face.jpg alt class=first>
<img src=https://s3-us-west-2.amazonaws.com/s.cdpn.io/4273/julia.jpg alt class=second>
<img src=https://s3-us-west-2.amazonaws.com/s.cdpn.io/4273/julia.jpg alt class=second>
<img src=https://s3-us-west-2.amazonaws.com/s.cdpn.io/4273/julia.jpg alt class=second>
<img src=https://s3-us-west-2.amazonaws.com/s.cdpn.io/4273/julia.jpg alt class=second>
<img src=https://s3-us-west-2.amazonaws.com/s.cdpn.io/4273/julia.jpg alt class=second>
<img src=https://s3-us-west-2.amazonaws.com/s.cdpn.io/4273/julia.jpg alt class=second>
<img src=https://s3-us-west-2.amazonaws.com/s.cdpn.io/4273/julia.jpg alt class=second>
<img src=https://s3-us-west-2.amazonaws.com/s.cdpn.io/4273/julia.jpg alt class=second>
<img src=https://s3-us-west-2.amazonaws.com/s.cdpn.io/4273/julia.jpg alt class=second>
<img src=https://s3-us-west-2.amazonaws.com/s.cdpn.io/4273/julia.jpg alt class=second>
</figure>

提前致谢!

0 个答案:

没有答案