【css】11.动画效果transiton(1)

transition: 0.2s left;

这是一个高度为2px,有背景的下划线条的动画效果

.content-line {
    position: absolute;
    left: 0;
    bottom: -12Px;
    height: 2Px;
    background-color: #C54242;
    transition: 0.2s left;
  }

0.2秒的过度效果

.list-item {
    width: calc(calc(100% / 5) - 15Px);
    background-color: #FFF4E7;
    transition: 0.2s background-color;
    margin-right: 20Px;
    cursor: pointer;
    .list-img {
      height: 180Px;
      width: 100%;
      img{
        width: 100%;
        height: 100%;
      }
    }
  }

3实战效果 注意style里面的效果,一般都是切换时候才有过度效果

<template>
  <div class="home">
    <div class="demo" id="demo">color and background</div>
    <button id="color" @click="colorUN">click me toggle color</button>
    <button id="bg" @click="clickBG">click me toggle background-color</button>
  </div>
</template>
<script>
export default {
  name: "Home",
  data() {
    return {};
  },
  methods: {
    colorUN() {
      const demo = document.querySelector("#demo");
      demo.style.color = `rgb(${parseInt(Math.random() * 256)},${parseInt(
        Math.random() * 256
      )},${parseInt(Math.random() * 256)})`;
      let num = parseInt(Math.random() * 60);
      demo.style.fontSize = `${num}px`;
    },
    clickBG() {
      const demo = document.querySelector("#demo");
      demo.style.backgroundColor = `rgb(${parseInt(
        Math.random() * 256
      )},${parseInt(Math.random() * 256)},${parseInt(Math.random() * 256)})`;
    },
  },
};
</script>
<style lang="scss" scoped>
.demo {
  transition: 1s color, 0.2s background-color,2s font-size;
}
button {
  margin-top: 10px;
}
</style>

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

前端小云儿

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值