旋转按钮组件

效果图

在这里插入图片描述

Man JS

import styles from './style.less'
import TurnButton from '@/common/TurnButton'
const index = () =>
{
    return (
        <div className={styles.container}>
            <TurnButton value={'套你猴子'} render={(name) =>
            {
                return (<button className={styles.rotateBtn}>{name}</button>);
            }} ></TurnButton>
        </div>
    );
};
export default index

Man CSS

.container {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  background-color: pink;
  box-sizing: border-box;

  .rotateBtn {
    width: 120px;
    height: 70px;
    color: #0ebeff;
    // ! 边框颜色
    background: #fff;
    cursor: pointer;

    // 滚动的颜色
    &::before {
      background-color: yellow;
    }

    // 背景颜色
    &::after {
      background: #000;
    }

    // 鼠标经过停止动画
    &:hover::before {
      animation-play-state: paused;
    }

    // 鼠标经过线占满屏
    &:hover {
      background: yellow;
    }
  }
}

TurnButton JS

import styles from './style.less'
const index = ({ value, render }) =>
{
    return (
        <div className={styles.buttonContainer}>
            {render(value)}
        </div>
    );
};
export default index

TurnButton CSS

.buttonContainer {
  position: relative;

  button {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 200px;
    height: 80px;
    color: #0ebeff;
    font-size: 24px;
    background: #000;
    border: none;
    outline: none;
    z-index: 1;
    border-radius: 10px;
    // outline: 4px solid #fff;
    overflow: hidden;

    &::before {
      content: '';
      position: absolute;
      background-color: #0ebeff;
      width: 200%;
      height: 200%;
      z-index: -2;
      left: 50%;
      top: 50%;
      animation: rotate 3s infinite linear;
      transform-origin: 0 0;
    }

    &::after {
      content: '';
      position: absolute;
      background: #000;
      width: calc(100% - 4px);
      height: calc((100% - 4px));
      left: 2px;
      top: 2px;
      border-radius: 10px;
      z-index: -1;
    }
  }

  @keyframes rotate {
    to {
      transform: rotate(1turn);
    }
  }
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

臧小川

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

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

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

打赏作者

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

抵扣说明:

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

余额充值