为径向渐变动画CSS3:从左移到右? [英] animate radial-gradient CSS3 : move from left to right?

查看:880
本文介绍了为径向渐变动画CSS3:从左移到右?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用径向渐变 radial-gradient(圆形,rgba(255,255,255,0.8)0,rgba(255,255,255,0)100%)制作背景动画,,将其从左移到右

I want animate a background with a radial-gradient radial-gradient(circle, rgba(255,255,255,0.8) 0, rgba(255,255,255,0) 100%), to move it from left to right

http:// jsfiddle.net/odsb1fjh/2/

我该如何制作此径向渐变的动画以使div上的无限从左向右移动?

how can I do to animate this radial-gradient to move infinite on div from left to right?

我已经尝试过动画和关键帧的背景位置:左/右下;但不起作用。

I have already try animation and keyframe background-position: left/right bottom; but don't works.

推荐答案

但是我们可以看到正方形的边界,其中径向半径在哪里-为什么完全使用放射状背景,只需使用:

"but we can see the border of "square" where is the light radial" - Why use radial background at all, simply use:

div

div {
  position: absolute;
  width: 250px;
  height: 250px;
  background-color: black;
  background-image: url(http://frontend.lostboys.nl/presenations/Icons-fonts/img/chrome.png);
  overflow: hidden;
}
div:after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgb(255, 255, 255);
  background: linear-gradient(
    90deg,
    rgba(250, 250, 250, 0) 0%,
    rgba(250, 250, 250, 0.5) 60%,
    rgba(250, 250, 250, 0) 100%
  );
  -webkit-animation: animation 3s ease-in-out infinite;
}
@-webkit-keyframes animation {
  from {
    left: -250px;
  }
  to {
    left: 250px;
  }
}

<div></div>

这篇关于为径向渐变动画CSS3:从左移到右?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆