外边框动态旋转

旋转动画效果实现
本文介绍了一个使用Vue.js创建的旋转动画效果,通过内外两个环形元素的相反方向旋转,配合中心头像,营造出视觉上的动态美感。文章提供了完整的代码示例,包括HTML结构、CSS动画及Vue组件定义。

效果图(由于是截图,看不出动态效果): 

代码:

图片素材:

<template>
  <div>
    <div class="box">
      <div class="ring-outer"></div>
      <div class="ring-inner"></div>
      <div class="avatar"></div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {};
  },

  methods: {},

  created() {}
};
</script>
<style>
.box {
  position: relative;
  width: 220px;
  height: 220px;
  display: flex;
  justify-content: center;
  align-items: center;
}
.ring-inner {
  height: 220px;
  width: 220px;
  position: absolute;
  background: url('../assets/ring-inner.png') no-repeat;
  background-size: 90%;
  background-position: center;
  animation: clockwise 3s linear infinite;
}
.ring-outer {
  height: 220px;
  width: 220px;
  position: absolute;
  background: url('../assets/ring-outer.png') no-repeat;
  background-size: 100%;
  background-position: center;
  animation: anti-clockwise 3s linear infinite;
}
.avatar {
  height: 160px;
  width: 160px;
  background: url('../assets/timg.jpg');
  background-size: 166%;
  background-position: center;
  border-radius: 50%;
}
@keyframes clockwise {
  100% {
    transform: rotate(360deg);
  }
}
@keyframes anti-clockwise {
  0% {
    transform: rotate(360deg);
  }
}
</style>


 

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值