2-9,麻烦老师检查一下!

来源:2-9 自由编程

脑袋瓜瓜嗡嗡的

2022-05-12 23:39:50

<!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;
        }
        div{
            position: relative;
            width: 300px;
            height: 240px;
            overflow: hidden;
        }
        img{
            width: 300px;
            height: 240px;
        }
        p{
            position: absolute;
            left: 0;
            bottom:-20px;
            width: 300px;
            height: 20px;
            line-height: 20px;
            font-size: 16px;
            color: white;
            text-align: center;
            background-color: rgba(0,0,0,.5);
            transition: bottom 1s ease 0s;
           
        }
        div:hover p{
            bottom: 0;
        }
    </style>
</head>
<body>
    <div>
        <img src="image/duck.png" alt="">
        <p>这是一只小鸭</p>
    </div>
</body>
</html>


写回答

1回答

好帮手慕星星

2022-05-13

同学你好,代码实现效果很棒。继续加油,祝学习愉快!

0

前端工程师

前端入门如同写字,如果你不知道从哪开始,那就选择前端(含Vue3.x,React17,TS)

20327 学习 · 17877 问题

查看课程