明星资料卡(HTML、CSS)

此HTML代码示例展示了如何使用CSS实现一个响应式的图片盒,当鼠标悬停时,图片会向右滑动并变为半透明,同时标题和三个段落通过不同的动画效果从不同方向显现。这种设计结合了定位和过渡属性,为网页元素添加动态交互体验。
摘要由CSDN通过智能技术生成
<!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;
            padding: 0;
        }
        img{
            display: block;
        }
        .box{
            width: 350px;
            border:5px solid red;
            margin: 0 auto;
            position: relative;
            overflow: hidden;
        }
        .box img{
            width: 100%;
            transition: all 1s;
        }
        .box:hover img{
            transform: translateX(50px);
            opacity: 0.5;
        }
        .box h2{
            position:absolute;
            left: 50px;
            top: 10px;
            color: white;
            transition: all 1s;
        }
        .box:hover h2{
            transform: translateX(100px);
        }
        .box p{
            position: absolute;
            left: 50px;
            width:100px;
            color:white;
            background: darkblue;
            transition: all 1s;
        }
        .box .p1{
            top: 100px;
            transform: translateY(400px);
        }
        .box:hover .p1{
            transform: translateY(0px);
        }
        .box .p2{
            top:200px;
            transform: translateX(500px);
        }
        .box:hover .p2{
            transform: translateX(0px);
        }
        .box .p3{
            top: 300px;
            transform: translateX(-500px);
        }
        .box:hover .p3{
            transform: translateX(0px);
        }
    </style>
</head>
<body>
    <div class="box">
        <img src="img\1.png" alt="">
        <h2>title</h2>
        <p class="p1">111</p>
        <p class="p2">222</p>
        <p class="p3">333</p>
    </div>
</body>
</html>

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值