<template> <div class="box"> <div class="button">按钮</div> </div> </template> <style> .box { display: flex; justify-content: center; } .button { width: 100px; height: 40px; line-height: 40px; text-align: center; /* border: 3px solid #000; */ border-radius: 5px; position: relative; overflow: hidden; } .button::before { content: ""; width: 200%; height: 200%; position: absolute; background: red; z-index: -2; left: 50%; top: 50%; transform-origin: 0 0; animation: rotate 2s infinite linear; } .button::after { content: ""; width: calc(100% - 4px); height: calc(100% - 4px); background: rgb(255, 255, 255); border-radius: 5px; position: absolute; left: 2px; top: 2px; z-index: -1; } </style>