纯CSS3悬停文字边框动画特效

<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>纯CSS3悬停文字边框动画特效</title>
    <style>
        body {
            margin: 0;
            padding: 0;
            height: 100vh;
            display: flex;
            justify-content: center;
            align-items: center;
            background: #1a1a2e;
            font-family: 'Arial', sans-serif;
            overflow: hidden;
        }

        .container {
            text-align: center;
        }

        .hover-text {
            position: relative;
            display: inline-block;
            font-size: 4rem;
            color: transparent;
            -webkit-text-stroke: 1px #fff;
            text-stroke: 1px #fff;
            margin: 20px;
            padding: 10px 30px;
            cursor: pointer;
            transition: all 0.3s ease;
        }

        /* 边框动画效果 */
        .hover-text::before,
        .hover-text::after {
            content: '';
            position: absolute;
            width: 0;
            height: 0;
            opacity: 0;
            transition: all 0.5s ease;
            box-sizing: border-box;
        }

        /* 上边框 */
        .hover-text::before {
            top: 0;
            left: 0;
            border-top: 2px solid #00f5d4;
            border-right: 2px solid #00f5d4;
        }

        /* 下边框 */
        .hover-text::after {
            bottom: 0;
            right: 0;
            border-bottom: 2px solid #ff0a54;
            border-left: 2px solid #ff0a54;
        }

        /* 悬停效果 */
        .hover-text:hover {
            color: #fff;
            text-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
        }

        .hover-text:hover::before,
        .hover-text:hover::after {
            width: 100%;
            height: 100%;
            opacity: 1;
        }

        /* 不同方向的动画效果 */
        .effect-1:hover::before {
            transition-delay: 0s;
        }

        .effect-1:hover::after {
            transition-delay: 0.2s;
        }

        .effect-2:hover::before {
            transition-delay: 0.4s;
        }

        .effect-2:hover::after {
            transition-delay: 0.6s;
        }

        .effect-3:hover::before {
            transition-delay: 0.8s;
        }

        .effect-3:hover::after {
            transition-delay: 1s;
        }

        /* 背景装饰元素 */
        .bg-element {
            position: absolute;
            width: 200px;
            height: 200px;
            border-radius: 50%;
            background: rgba(0, 245, 212, 0.1);
            filter: blur(30px);
            z-index: -1;
            animation: float 15s infinite ease-in-out;
        }

        .bg-element:nth-child(1) {
            top: 20%;
            left: 10%;
            animation-delay: 0s;
        }

        .bg-element:nth-child(2) {
            top: 60%;
            left: 70%;
            animation-delay: 3s;
        }

        .bg-element:nth-child(3) {
            top: 30%;
            left: 50%;
            animation-delay: 6s;
        }

        .bg-element:nth-child(4) {
            top: 70%;
            left: 20%;
            animation-delay: 9s;
        }

        @keyframes float {
            0%, 100% {
                transform: translate(0, 0);
            }
            25% {
                transform: translate(50px, 50px);
            }
            50% {
                transform: translate(0, 100px);
            }
            75% {
                transform: translate(-50px, 50px);
            }
        }

        /* 版权信息 */
        .footer {
            position: absolute;
            bottom: 20px;
            right: 20px;
            color: rgba(255, 255, 255, 0.5);
            font-size: 12px;
        }

        .footer a {
            color: #00f5d4;
            text-decoration: none;
        }

        .footer a:hover {
            text-decoration: underline;
        }
    </style>
</head>
<body>
    <div class="container">
        <h1 class="hover-text effect-1">悬停效果</h1>
        <h1 class="hover-text effect-2">CSS3动画</h1>
        <h1 class="hover-text effect-3">边框特效</h1>
        
        <!-- 背景装饰元素 -->
        <div class="bg-element"></div>
        <div class="bg-element"></div>
        <div class="bg-element"></div>
        <div class="bg-element"></div>
    </div>
    
</body>
</html>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值