【问题标题】:How to keep the animation property within that element which is at top如何将动画属性保留在顶部的元素中
【发布时间】:2021-07-30 15:03:59
【问题描述】:

我制作了一个包含简单动画弹跳的类弹出窗口。html 部分如下:-

那么如何防止popup中的动画进入id open-btn CSS 是这样的:-

.slanted {
  margin-left: 440px;
  /* transform: skewX(25deg); */
  color: yellowgreen;
  font-size: 54px;
  /* margin-top: 16px; */
  overflow: visible;
  animation-name: bounce;
  animation-duration: 2s;
  animation-iteration-count: infinite;
}

@keyframes bounce {
  from {
    margin-top: 0px;
  }
  to {
    margin-top: 16px;
  }
}

#open-btn {
  color: rgb(0, 0, 0);
  font-weight: bolder;
  font-size: 32px;
  background-color: rgb(47, 47, 236);
  width: 270px;
  height: 80px;
  margin-top: 350px;
  margin-left: 520px;
  text-align: center;
  padding: 16px;
  cursor: pointer;
}
<div class="popup">
  <div class="slanted">
    I am Veer Shah
  </div>
</div>
<div id="open-btn">Download CV</div>

【问题讨论】:

    标签: html css animation


    【解决方案1】:

    这是因为您正在为动画使用 ma​​rgin 属性。当您增加 div 元素的上边距时,它会导致其下方的所有 html 元素向下移动该数量,因此看起来 open-btn 元素也是动画的一部分。为了让您的动画正常工作,请使用 CSS 中的正确位置属性。 Here 这可能会有所帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-09-09
      • 1970-01-01
      • 1970-01-01
      • 2012-04-04
      • 2016-04-17
      • 2018-07-02
      • 1970-01-01
      • 2020-01-30
      相关资源
      最近更新 更多