html和css实现hover图片上浮效果

博客主要展示了HTML代码和CSS代码,还给出了完整代码以及效果图,聚焦于前端开发中HTML和CSS的应用。
摘要由CSDN通过智能技术生成

目录

1、html代码

2、css代码

 完整代码

效果图:


1、html代码

    <div>
        <span></span>
        <span></span>
        <span></span>
    </div>

2、css代码

  body{
            background-color: black;
          
        }
        div{
            width: 1000px;
            height: 400px;
            display: inline-flex;
            justify-content: center;
            align-items: center;
            margin: 100px auto;
            /* border: 3px solid red; */
        }
        span{
            display: inline-block;
            width: 200px;
            height: 250px;
            margin-right: 50px;
            transition: all 0.5s;
        }
        span:nth-child(1){
            background-color: violet;
        }
        span:nth-child(2){
            background-color: lightseagreen;
        }
        span:nth-child(3){
            background-color: orangered;
        }
        span:hover{
            box-shadow: 0px 0px 5px rgba(255, 255, 255,0.2);
            transform: translate3d(0,-4px,0);
            cursor: pointer;
        }

 完整代码

<!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>
        body{
            background-color: black;
          
        }
        div{
            width: 1000px;
            height: 400px;
            display: inline-flex;
            justify-content: center;
            align-items: center;
            margin: 100px auto;
            /* border: 3px solid red; */
        }
        span{
            display: inline-block;
            width: 200px;
            height: 250px;
            margin-right: 50px;
            transition: all 0.5s;
        }
        span:nth-child(1){
            background-color: violet;
        }
        span:nth-child(2){
            background-color: lightseagreen;
        }
        span:nth-child(3){
            background-color: orangered;
        }
        span:hover{
            box-shadow: 0px 0px 5px rgba(255, 255, 255,0.2);
            transform: translate3d(0,-4px,0);
            cursor: pointer;
        }
    </style>
</head>
<body>
    <div>
        <span></span>
        <span></span>
        <span></span>
    </div>
</body>
</html>

效果图:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值