点赞收藏爱心动画效果

代码语言:html

所属分类:动画

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">

<style>
@charset "UTF-8";
*, *:before, *:after {
  position: relative;
  box-sizing: border-box;
}

:root {
  --color-bg: #FDF1F2;
  --color-heart: #EA442B;
  --easing: cubic-bezier(.7,0,.3,1);
  --duration: .5s;
}

html, body {
  height: 100%;
  width: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
}

.like-button {
  font-size: 35vmin;
  -webkit-appearance: none;
     -moz-appearance: none;
          appearance: none;
  border: none;
  border-radius: 50%;
  background: white;
  width: 1em;
  height: 1em;
  padding: 0;
  margin: 0;
  outline: none;
  z-index: 2;
  -webkit-transition: -webkit-transform var(--duration) var(--easing);
  transition: -webkit-transform var(--duration) var(--easing);
  transition: transform var(--duration) var(--easing);
  transition: transform var(--duration) var(--easing), -webkit-transform var(--duration) var(--easing);
  cursor: pointer;
}
.like-button:before {
  z-index: -1;
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  box-shadow: 0 0.3em 0.6em rgba(0, 0, 0, 0.3);
  border-radius: inherit;
  -webkit-transition: inherit;
  transition: inherit;
}
.like-button:after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: #fff;
  border-radius: inherit;
  z-index: -1;
}
.like-button:active:before {
  -webkit-animation: depress-shadow var(--duration) var(--easing) both;
          animation: depress-shadow var(--duration) var(--easing) both;
}
.like-button:focus:after {
  -webkit-animation: depress var(--duration) var(--easing) both;
          animation: depress var(--duration) var(--easing) both;
}
@-webkit-keyframes depress {
  from, to {
    -webkit-transform: none;
            transform: none;
  }
  50% {
    -webkit-transform: translateY(5%) scale(0.9);
            transform: translateY(5%) scale(0.9);
  }
}
@keyframes depress {
  from, to {
    -webkit-transform: none;
            transform: none;
  }
  50% {
    -webkit-transform: translateY(5%) scale(0.9);
            transform: translateY(5%) scale(0.9);
  }
}
@-webkit-keyframes depress-shadow {
  from, to {
    -webkit-transform: none;
            transform: none;
  }
  50% {
    -webkit-transform: scale(0.5);
            transform: scale(0.5);
  }
}
@keyframes depress-shadow {
  from, to {
    -webkit-transform: none;
            transform: none;
  }
  50% {
    -webkit-transform: scale(0.5);
            transform: scale(0.5);
  }
}
.like-wrapper {
  display: grid;
  -webkit-box-align: center;
          align-items: center;
  -webkit-box-pack: center;
          justify-content: center;
  z-index: 1;
}
.like-wrapper > * {
  margin: auto;
  grid-area.........完整代码请登录后点击上方下载按钮下载查看

网友评论0