jquery - 为背景和内容设置动画

标签 jquery html css animation


我正在尝试为启动画面制作动画,我可以为 Logo 制作动画,但是当我尝试为背景制作动画时,整体动画效果不起作用。
我在这里试过https://jsfiddle.net/sureshpattu/yu2afj7b/ :
这是我的 scss:

 .container {
   display: table;
   width: 100%;
   height: 100vh;
   background: #ddd;
   margin: 20px;
 }

 .page {
   //Intro Screen
   &__intro {
     display: table-cell;
     vertical-align: middle;
     transition: all 0.2s ease-in-out;
     img {
       width: 150px;
       transition: all 0.2s ease-in-out;
     }
     &-wrapper {
       position: fixed;
       top: 0;
       right: 0;
       bottom: 0;
       left: 0;
       z-index: 10;
       display: table;
       width: 100%;
       height: 100vh;
       background: #fff;
       text-align: center;
     }
     &--hidden {
       img {
         width: 0;
         transition: all 0.2s ease-in-out;
       }
     }
   }
 }

这是 html:

<div class="container">
  <div class="page__intro-wrapper">
    <div class="page__intro">
      <img src="http://szmob.rbahn.com/img/sz-logo.svg" />
    </div>
  </div>
</div>

最佳答案

据我从您的帖子中了解到,您正在尝试使用 .page__intro-wrapper 类对 div 进行任何处理。问题出在您的 scss 中,您正在将 .page__intro--hidden 类添加到该类内的图像中,而不是所需的 div。 换句话说,改变这个:

 &--hidden {
   img {
     width: 0;
     transition: all 0.2s ease-in-out;
   }
 }

为此:

 &--hidden {
   img {
     width: 0 !important;
     transition: all 0.2s ease-in-out;
   }
     width: 0 !important;
     transition: all 0.2s ease-in-out;
 }

这是 fiddle :https://jsfiddle.net/johannesMt/yu2afj7b/3/

关于jquery - 为背景和内容设置动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35479815/

相关文章:

PHP图像显示

html - 在ajax中用jquery更新css?

jquery - 显示以前隐藏的 Bootstrap 警报

html - 如何在 html 中的动态尺寸图像上放置一些动态尺寸链接?

css - 对网络应用程序尺寸的百分比感到困惑

html - 需要帮助让 oracle "SORT BY"以我想要的方式工作

javascript - jQuery 从外部 html 加载内容

javascript - 通过 GET 仅发送已填充的字段

html - CSS 动画 - 图像加倍

javascript - 单独编译 Angular 组件并在 HTML 页面中一起使用它们