我在按照这个教程:https://cloudcannon.com/deconstructions/2014/11/15/facebook-content-placeholder-deconstruction.html,创建一个虚假的加载器。 不幸的是,这个教程包含固定像素值,而我希望它适用于所有尺寸的屏幕。 所以我做了以下调整来实现动画效果:
@keyframes placeHolderShimmer {
0% {
background-position: -30vw 0
}
100% {
background-position: 30vw 0
}
}
.c-animated-background {
animation-duration: 1.5s;
animation-fill-mode: forwards;
animation-iteration-count: infinite;
animation-name: placeHolderShimmer;
animation-timing-function: linear;
background: fff;
background: linear-gradient(to right, #eeeeee 8%, #dddddd 18%, #eeeeee 33%);
height: 100%;
width: 100%;
position: relative;
padding-top: 50px;
-webkit-backface-visibility: hidden
}
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="style.css">
<script src="script.js"></script>
</head>
<body class="c-animated-background">
</body>
</html>
以下是一个plunker链接: https://plnkr.co/edit/X8PBIUYmAC11LCUV9uTy?p=preview
100vw
和-100vw
。将速度提高到5s
,它与您现在拥有的速度相同。例子 - misterManSam