按钮滚动边框

button {
        position: relative;
        border: none;
        z-index: 1;
        outline: none;
        border-radius: 12px;
        cursor: pointer;
        overflow: hidden;
        width: 100px;
        height: 50px;
        background: #333;
        
    }
    button::before {
        content: '';
        position: absolute;
        width: 200%;
        height: 200%;
        background: red;
        z-index: -2;
        left: 50%;
        top: 50%;
        transform-origin: left top;
        animation: rotation 2s linear infinite;
    }
    button::after {
        content: '';
        position: absolute;
        --g: 2px;
        width: calc(100% - var(--g) * 2);
        height: calc(100% - var(--g) * 2);
        background: #fff;
        left: var(--g);
        top: var(--g);
        border-radius: inherit;
        z-index: -1;
    }
    @keyframes rotation {
        to {
            transform: rotate(360deg);
        }
    }
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容