CSS3实现字符跳动与颜色渐变

 html

<p>小小的世界,大大的梦想</p>
<div class="dance">
    <span class="word">l</span>
    <span class="word">o</span>
    <span class="word">c</span>
    <span class="word">a</span>
    <span class="word">l</span>
    <span class="word">h</span>
    <span class="word">o</span>
    <span class="word">s</span>
    <span class="word">t</span>
    <span class="word">:</span>
    <span class="word">8</span>
    <span class="word">0</span>
    <span class="word">8</span>
    <span class="word">0</span>
</div>

css3

​p {
  font-size: xx-large;
  background: -webkit-linear-gradient(135deg,
        #0eaf6d,
        #ff6ac6 25%,
        #147b96 50%,
        #e6d205 55%,
        #2cc4e0 60%,
        #8b2ce0 80%,
        #ff6384 95%,
        #08dfb4);
  /* 文字颜色填充设置为透明 */
  -webkit-text-fill-color: transparent;
  /* 背景裁剪,即让文字使用背景色 */
  background-clip: text;
  /* 背景图放大一下,看着柔和一些 */
  background-size: 200% 100%;
  /* 应用动画flowCss 12秒速度 无限循环 线性匀速动画*/
  animation: flowCss 12s infinite linear;
}
.dance {
    align-items: center;
    justify-content: center;
    font-size: xx-large;
    font-weight: bold;
    white-space: nowrap;
    cursor: pointer;
    margin-left: 20px;
  }

  .word {
    /* alternate 轮流反向播放 A--B--A--B... 必须要加 */
    animation: dance 0.72s cubic-bezier(0.05, 0, 0.2, 1) infinite alternate;
    display: inline-block;
    transform: translate3d(0, 0, 0);
    font-size: xx-large;
    text-decoration: underline;
    color: #75b9ff;
    margin-right: 1px;
  }

  .word:nth-child(1) {
    animation-delay: 0s;
  }

  .word:nth-child(2) {
    animation-delay: 0.0333333333s;
  }

  .word:nth-child(3) {
    animation-delay: 0.1333333333s;
  }

  .word:nth-child(4) {
    animation-delay: 0.2333333333s;
  }

  .word:nth-child(5) {
    animation-delay: 0.3333333333s;
  }

  .word:nth-child(6) {
    animation-delay: 0.4333333333s;
  }

  .word:nth-child(7) {
    animation-delay: 0.5333333333s;
  }

  .word:nth-child(8) {
    animation-delay: 0.6333333333s;
  }

  .word:nth-child(9) {
    animation-delay: 0.7333333333s;
  }

  .word:nth-child(10) {
    animation-delay: 0.8333333333s;
  }

  .word:nth-child(11) {
    animation-delay: 0.9333333333s;
  }
  .word:nth-child(12) {
    animation-delay: 1.0333333333s;
  }
  .word:nth-child(13) {
    animation-delay: 1.1333333333s;
  }
  .word:nth-child(14) {
    animation-delay: 1.2333333333s;
  }

  @keyframes dance {
    0% {
      transform: translate3d(0, 0, 0);
    }

    100% {
      transform: translate3d(0, -0.54em, 0);
    }
  }

​

  • 8
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
### 回答1: CSS3 中可以使用 border-radius 属性实现圆边框,而要实现圆边框的渐变,可以使用 border-image 属性和 linear-gradient() 函数。具体代码如下: ```css border-radius: 50%; border-image: linear-gradient(to right, red, blue) 1; ``` 其中,border-radius 设置圆边框的半径,border-image 设置边框图片,linear-gradient() 函数设置渐变颜色,1 为边框宽度。 ### 回答2: 在CSS3中,我们可以使用border-radius属性来实现圆边框的效果,并结合linear-gradient函数来实现渐变效果。 首先,我们需要设置元素的宽度和高度相等,以便创建一个圆形的容器。然后,使用border-radius属性将边框的形状设置为圆形。 接下来,我们需要添加渐变效果。可以使用linear-gradient函数来定义渐变的方向和颜色。该函数接受一个或多个颜色值作为参数,可以设置颜色的起始位置和结束位置。 例如,要创建一个从红色到蓝色渐变的圆形边框,可以使用以下CSS代码: ``` div { width: 200px; height: 200px; border-radius: 50%; border: 4px solid; border-image: linear-gradient(to right, red, blue) 1; } ``` 以上代码中,div元素的宽度和高度设置为200px,使用border-radius属性将边框的形状设置为圆形。border属性设置边框的宽度和样式,border-image属性定义了渐变的方向和颜色。 这样,我们就可以实现一个具有圆边框渐变效果的元素。根据需要,你可以调整渐变的方向、起始和结束位置,以及颜色的数量和位置来自定义样式。 ### 回答3: 在CSS3中,可以通过使用border-radius属性以及background属性来实现圆边框的渐变效果。 首先,可以使用border-radius属性设置元素的圆角弧度,使其变为一个圆形。 例如: div { border-radius: 50%; } 然后,可以使用background属性为元素设置渐变背景。可以使用linear-gradient函数来定义渐变的起始颜色和结束颜色。 例如: div { background: linear-gradient(red, blue); } 上述代码将会使元素的背景呈现从红色到蓝色的渐变效果。 最后,将上述两个属性结合在一起,即可实现圆边框的渐变效果。 例如: div { border-radius: 50%; background: linear-gradient(red, blue); } 这样,元素的边框将被渐变颜色所填充,并且边框将呈现圆形的形状。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值