随手记-流光边框按钮

101 阅读1分钟
body {
    background: #000;
}

.btn {
    position: relative;
    width: 160px;
    height: 60px;
    line-height: 60px;
    margin: 200px 500px;
    text-align: center;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    outline: 4px solid #fff;
    background: transparent;
    color: aqua;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    width: 200%;
    height: 200%;
    background: red;
    left: 50%;
    top: 50%;
    z-index: -2;
    transform-origin: left top;
    animation: rotation 3s infinite linear;
}

.btn::after {
    content: '';
    position: absolute;
    width: calc(100% - 10px);
    height: calc(100% - 10px);
    left: 5px;
    top: 5px;
    background: #000;
    overflow: hidden;
    z-index: -1;
}

@keyframes rotation {
    to {
        transform: rotate(1turn);
    }
}