javascript - 重新创建此预加载屏幕——看起来像 gif 而不是编码动画

标签 javascript jquery html css

编码新手在这里! 几个小时以来,我一直在尝试重新创建此预加载屏幕 ( http://addpbj.com ),但我似乎无法做到正确。所有在线教程都在展示如何制作动画旋转器和加载器,但我喜欢 Logo 的颤动。我觉得我正在以错误的方式解决这个问题。我一直在尝试将附加的 gif 作为我的预加载屏幕。 到目前为止,这是我的代码:

    <div id="dvLoading"></div>
*/----CSS----/*
   #dvLoading{
    background:#000       url(https://media.giphy.com/media/l4JyJHAF8blvfplf2/source.gif) no-repeat center center;
  display: blocks;
  position:relative;
  left: 50%;
  top: 50%;
  height: 150px;
  width: 150px;
  position: fixed;
  z-index: 1000;
   margin: -75px 0 0 -75px;
}
*/----JQ----/*
        $(window).load(function(){
       $('#dvLoading').fadeOut(2000);
    });

(http://codepen.io/anon/pen/MJGPQG) . jquery有什么问题吗?

任何帮助将不胜感激。

最佳答案

这只是一个缩放和不透明度循环。

body{
  background: #ed4424;
  position: relative;
  height: 100vh;
}

img{
  position: absolute;
  width:100px;
  height: 100px;
  left: 50%;
  top: 50%;
  transform-origin: left;
  -webkit-animation: THROB 8s infinite;
  -moz-animation:    THROB 8s infinite;
  -o-animation:      THROB 8s infinite;
  animation:         THROB 8s infinite;
}

@-webkit-keyframes THROB {
  0%   { opacity: 1; transform: scale(1) translate(-50%,-50%); }
  50%  { opacity: 0.4; transform: scale(0.7) translate(-50%,-50%); }
  100% { opacity: 1; transform: scale(1) translate(-50%,-50%); }
}
@-moz-keyframes THROB {
  0%   { opacity: 1; transform: scale(1) translate(-50%,-50%); }
  50%  { opacity: 0.4; transform: scale(0.7) translate(-50%,-50%); }
  100% { opacity: 1; transform: scale(1) translate(-50%,-50%); }
}
@-o-keyframes THROB {
  0%   { opacity: 1; transform: scale(1) translate(-50%,-50%); }
  50%  { opacity: 0.4; transform: scale(0.7) translate(-50%,-50%); }
  100% { opacity: 1; transform: scale(1) translate(-50%,-50%); }
}
@keyframes THROB {
  0%   { opacity: 1; transform: scale(1) translate(-50%,-50%); }
  50%  { opacity: 0.4; transform: scale(0.7) translate(-50%,-50%); }
  100% { opacity: 1; transform: scale(1) translate(-50%,-50%); }
}
<img src="http://static1.squarespace.com/static/56d8893cb09f9547596ab9f7/t/56d9a10fe707eb99e3cf68c3/1485878555441/?format=1500w">

关于javascript - 重新创建此预加载屏幕——看起来像 gif 而不是编码动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42032103/

相关文章:

javascript - 为什么页面刷新一次?

javascript - Mongoose 模型中的 model 和 model._doc 有什么区别?

javascript - 水线查询最近7天内创建的记录?

html - 为什么 flex 元素不缩小过去的内容大小?

JavaScript 函数指针

javascript - JS 点击时不触发

jquery - Twitter Bootstrap 菜单根据脚本的顺序表现不同

javascript - 如何捕获所有ajax请求被接收的事件

javascript - 通过单击按钮切换 BODY 元素的背景颜色(CSS 类)时如何更改 H2 颜色?

html - 使用 flex 将列表分成相同元素的列