비전공자 개발일기

Rotating border 본문

HTML _CSS

Rotating border

HiroDaegu 2022. 11. 23. 14:06
728x90
SMALL

<!DOCTYPE html>
<html lang="ko">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>ROTATING BORDER</title>
    <link rel="stylesheet" href="style.css">
</head>
<body>
    <div class="conic conic-demo"></div>
</body>
</html>
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background-color: #000;
}

.conic {
    position: relative;
    z-index: 0;
    width: 400px;
    height: 300px;
    margin: 20px;
    padding: 2rem;
    border-radius: 10px;
    overflow: hidden;
}

.conic::before {
    content: "";
    position: absolute;
    z-index: -2;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background-color: #1A232A;
    background-repeat: no-repeat;
    background-position: 0 0;
    background-image: conic-gradient(transparent, rgba(168, 239, 255, 1), transparent 30%);
    animation: rotate 4s linear infinite;
}

@keyframes rotate {
    100% {
        transform: rotate(1turn);
    }
}

.conic::after {
    content: "";
    position: absolute;
    z-index: -1;
    top: 6px;
    left: 6px;
    width: calc(100% - 12px);
    height: calc(100% - 12px);
    background-color: #000;
    border-radius: 5px;
}

.conic-demo::after {
    animation: opacityChange 5s linear infinite;
}

@keyframes opacityChange {
    50% {
        opacity: .5;
    }
    100% {
        opacity: 1;
    }
}
728x90
LIST

'HTML _CSS' 카테고리의 다른 글

Aspect Ratio Calculator  (0) 2022.11.27
Liquid Drop Login page  (0) 2022.11.26
Postage Stamp Cutout  (0) 2022.11.22
Plus Neon BTN  (0) 2022.11.21
Sticky Cards  (0) 2022.11.20