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>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        
        body {
            display: flex;
            justify-content: center;
            align-items: center;
            min-height: 100vh;
            background: #f0f0f0;
            font-family: 'Arial', sans-serif;
        }
        
        .container {
            display: flex;
            flex-wrap: wrap;
            justify-content: center;
            gap: 40px;
            padding: 40px;
            max-width: 1200px;
        }
        
        .image-box {
            position: relative;
            width: 300px;
            height: 400px;
            overflow: hidden;
            border-radius: 10px;
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
        }
        
        .image-box img {
            width: 100%;
            height: 100%;
            object-fit: cover;
            transition: transform 0.5s;
        }
        
        .image-box:hover img {
            transform: scale(1.05);
        }
        
        .image-box::before,
        .image-box::after {
            content: '';
            position: absolute;
            width: 0;
            height: 0;
            border: 2px solid transparent;
            transition: all 0.5s ease;
            z-index: 2;
        }
        
        .image-box::before {
            top: 0;
            left: 0;
            border-top-color: #ff4757;
            border-left-color: #ff4757;
        }
        
        .image-box::after {
            bottom: 0;
            right: 0;
            border-bottom-color: #ff4757;
            border-right-color: #ff4757;
        }
        
        .image-box:hover::before,
        .image-box:hover::after {
            width: 100%;
            height: 100%;
        }
        
        .image-box .content {
            position: absolute;
            bottom: -100%;
            left: 0;
            width: 100%;
            padding: 20px;
            background: rgba(0, 0, 0, 0.7);
            color: #fff;
            transition: bottom 0.5s;
            z-index: 1;
        }
        
        .image-box:hover .content {
            bottom: 0;
        }
        
        .image-box .content h3 {
            margin-bottom: 10px;
            font-size: 24px;
            color: #ff4757;
        }
        
        .image-box .content p {
            font-size: 16px;
            line-height: 1.5;
        }
        
        .credit {
            position: fixed;
            bottom: 20px;
            color: #333;
            font-size: 14px;
        }
        
        .credit a {
            color: #ff4757;
            text-decoration: none;
        }
        
        .title {
            position: fixed;
            top: 20px;
            color: #333;
            font-size: 28px;
            font-weight: bold;
            text-align: center;
        }
    </style>
</head>
<body>
    <div class="title">CSS3悬停图片线条边框动画</div>
    
    <div class="container">
        <div class="image-box">
            <img src="https://source.unsplash.com/random/600x800?nature" alt="Nature">
            <div class="content">
                <h3>自然风光</h3>
                <p>探索大自然的美丽与神奇,感受地球最原始的魅力。</p>
            </div>
        </div>
        
        <div class="image-box">
            <img src="https://source.unsplash.com/random/600x800?city" alt="City">
            <div class="content">
                <h3>城市景观</h3>
                <p>现代都市的繁华景象,人类文明的集中体现。</p>
            </div>
        </div>
        
        <div class="image-box">
            <img src="https://source.unsplash.com/random/600x800?animal" alt="Animal">
            <div class="content">
                <h3>野生动物</h3>
                <p>地球上的奇妙生物,与我们共享这个星球。</p>
            </div>
        </div>
    </div>
    
</body>
</html>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值