首页 前端知识 html和css实现hover图片上浮效果

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

2024-06-10 11:06:08 前端知识 前端哥 113 441 我要收藏

目录

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>

效果图:

转载请注明出处或者链接地址:https://www.qianduange.cn//article/11771.html
标签
评论
发布的文章

第一次实验补充

2024-06-18 09:06:14

html5shiv,从入门到深入

2024-05-09 10:05:07

html5基础入门

2024-06-18 09:06:07

HTML5学习简记

2024-06-18 09:06:20

大家推荐的文章
会员中心 联系我 留言建议 回顶部
复制成功!