用css实现图片翻转 达成类似签到翻转照片效果

大体上的效果图

test.jpg

css部分

.hlist {
  display: inline-block;
  margin: 25px;
  position: relative;
}

.flip-container {
  perspective: 1000px;
}

.flip-container,.front,.back {
  width: 80px;
  height: 80px;
}

.flipper {
  transition: 1s;
  -webkit-transform-style: preserve-3d;
  -moz-transform-style: preserve-3d;
  -ms-transform-style: preserve-3d;
  -o-transform-style: preserve-3d;
  transform-style: preserve-3d;
  position: relative;
}

.front,.back {
  position: absolute;
  border-radius: 50%;
  overflow: hidden;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  /* Chrome 和 Safari */
  -moz-backface-visibility: hidden;
  /* Firefox */
  -ms-backface-visibility: hidden;
  /* Internet Explorer */
}

.hlist>p {
  width: 80px;
  text-align: center;
  position: absolute;
  bottom: -20px;
  left: 0;
  font-size: 16px;
  color: #717171;
  margin: 0;
}

.hlist .flo {
  color: #fff;
}

.back {
  -webkit-transform: rotateY(180deg);
  -moz-transform: rotateY(180deg);
  -ms-transform: rotateY(180deg);
  -o-transform: rotateY(180deg);
  transform: rotateY(180deg);
  position: relative;
}

.back .rightdown {
  position: absolute;
  width: 15px;
  height: 15px;
  right: 20px;
  bottom: 10px;
}

.flipper img {
  width: 80px;
  height: 85px;
}

.hid {
  width: 100%;
  height: 100%;
  position: absolute;
  left: 0;
  top: 0;
  background-color: rgba(0, 0, 0, .6);
}

html部分

js部分

不要忘了引入jquery,可以根据你想要的时间改变延时长短进行图片翻转

var imgs = document.querySelectorAll(".flipper");
setTimeout(function() {
    $(imgs[1]).css("transform","rotateY(180deg)");
}, 2000);
setTimeout(function() {
    $(imgs[2]).css("transform","rotateY(180deg)");
},4000);

你可能感兴趣的:(用css实现图片翻转 达成类似签到翻转照片效果)