仅将变换原点应用于一个角度

时间:2018-07-30 13:51:10

标签: css

我有一个动画按钮,该按钮从左侧移动,而右侧保持静止,它也从底部移动到顶部,我的目标是仅将底部变换属性应用于右下角,因此该按钮将在该角度向左折叠底角将保持静态,这是html部分:

.wrapper .btn.btn-display {
  position: relative;
  font-size: 1.75em;
  padding: 0 2em;
  color: #000;
  margin-top: .5em;
  background: transparent;
  transition: background-color .3s ease;
  text-decoration: none;
  border: none!important;
  border-radius: 0;
  line-height: 2;
  z-index: 1;
  font-family: 'Burbank', sans-serif;
  text-transform: uppercase;
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
  letter-spacing: 0;
}

.btn {
  display: inline-block;
  margin-bottom: 0;
  font-weight: 400;
  text-align: center;
  white-space: nowrap;
  vertical-align: middle;
  -ms-touch-action: manipulation;
  touch-action: manipulation;
  cursor: pointer;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  border: 1px solid transparent;
  margin: 100px 50px;
}

.wrapper .btn.btn-display:after {
  content: "";
  display: block;
  position: absolute;
  top: 0;
  right: 0;
  width: 100%;
  height: 2em;
  background-color: #ff0;
  -webkit-transition: background-color .3s ease-in-out;
  -o-transition: background-color .3s ease-in-out;
  transition: background-color .3s ease-in-out;
  -webkit-box-shadow: 0 4px 12px -4px rgba(0, 0, 0, .5);
  box-shadow: 0 4px 12px -4px rgba(0, 0, 0, .5);
  -webkit-animation: jelly 3s ease-in-out infinite alternate;
  animation: jelly 3s ease-in-out infinite alternate;
  -webkit-transform-origin: 95% 20% 20px;
  -ms-transform-origin: 95% 20% 20px;
  transform-origin: 95% 20% 20px;
}

.btn-display span {
  position: relative;
  z-index: 1;
  pointer-events: none;
}

@keyframes jelly {
  0 {
    transform: scaleX(1) scaleY(1);
    transform-origin: left center;
  }
  100% {
    transform: scaleX(1.05) scaleY(0.9);
  }
}
<div class="wrapper">
  <button class="btn btn-display"><span>Receive Present</span></button>
</div>

0 个答案:

没有答案