• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

div 边框旋转,纯 css

互联网 diligentman 2个月前 (12-01) 19次浏览

div 边框旋转

div 边框旋转,纯 css

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .con{
            position: relative;
            width: 200px;height: 200px;
            background: rgba(100, 100, 100, 0.349);
            overflow: hidden;
        }
        .div1{
            position: absolute;top: 0;
            height: 3px;width: 200px;
            background: rgb(75, 75, 240);
            transition: 1s;
            transform: translateX(-100%);
            animation: animate1 4s linear infinite;
        }
        .div2{
            position: absolute;right: 0;
            width: 3px;height:200px;
            background: rgb(75, 75, 240);
            transition: 1s;
            transform: translateY(-100%);
            animation: animate2 4s 1s linear infinite;
        }
        .div3{
            position: absolute;bottom: 0;
            height: 3px;width: 200px;
            background: rgb(75, 75, 240);
            transition: 1s;
            transform: translateX(100%);
            animation: animate3 4s 2s linear infinite;
        }
        .div4{
            position: absolute;left: 0;
            width: 3px;height: 200px;
            background: rgb(75, 75, 240);
            transition: 1s;
            transform: translateY(100%);
            animation: animate4 4s 3s linear infinite;
        }
        @keyframes animate1 {
            0%{
                transform: translateX(-100%);
            }
            50%,100%{
                transform: translateX(100%);
            }
        }
        @keyframes animate2 {
            0%{
                transform: translateY(-100%);
            }
            50%,100%{
                transform: translateY(100%);
            }
        }
        
        @keyframes animate3 {
            0%{
                transform: translateX(100%);
            }
            50%,100%{
                transform: translateX(-100%);
            }
        }
        @keyframes animate4 {
            0%{
                transform: translateY(100%);
            }
            50%,100%{
                transform: translateY(-100%);
            }
        }
    </style>
</head>
<body>
    <div class="con">
        <div class="div1"></div>
        <div class="div2"></div>
        <div class="div3"></div>
        <div class="div4"></div>
    </div>
    
</body>
</html>

给个赞吧,哈哈


喜欢 (0)