css实现幽灵按钮

【需求描述】css使用过渡,使用幽灵按钮。
在这里插入图片描述

<!DOCTYPE html>
<html lang="en">
<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>Document</title>
    <style>
        *{
      
      
            margin: 0;
            border: 0;
        }
        html{
      
      
            height: 100%;
            display: flex;
            align-items: center;
            justify-content: center;
            background: skyblue;
        }
        .btn{
      
      
            width: 200px;
            height: 50px;
            line-height: 50px;
            background: orange;
            text-align: center;

            position: relative;
        }
        .btn a{
      
      
            text-decoration: none;
            color: #fff;
            font: bold 20px Arial;
        }
        .btn-border-top,.btn-border-bottom{
      
      
            height: 5px;
            background: #fff;
            position: absolute;
            width: 0;
        }
        .btn-border-top{
      
      
            right: 0;
            top: 0;
        }
        .btn-border-bottom{
      
      
            left: 0;
            bottom: 0;
        }
        .btn:hover .btn-border-top{
      
      
            width: 100%;
            transition: width .3s;
            background: orange;
        }
        .btn:hover .btn-border-bottom{
      
      
            width: 100%;
            transition: width .3s;
            background: orange;
        }
        .btn:hover{
      
      
            background: #fff;
        }
        .btn:hover a{
      
      
            color: orange;
        }
    </style>
</head>
<body>
    <div class="btn">
        <div class="btn-border-top"></div>
        <a href="javascript:;">CSS3</a>
        <div class="btn-border-bottom"></div>
    </div>
</body>
</html>

猜你喜欢

转载自blog.csdn.net/qzw752890913/article/details/126265381