2-9自由编程练习,请老师检查

来源:2-9 自由编程

全栈开发工程师

2022-02-16 00:22:51

<!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>
        *{
            margin: 0;
            padding: 0;
        }
        .box{
            width: 400px;
            overflow: hidden;
            margin: 60px auto;
            position: relative;
        }
        .box img{
            width: 400px;
        }
        p{
            position: absolute;
            width: 390px;
            height: 50px;
            line-height: 50px;
            color: white;
            top: 325px;
            padding-left: 10px;
            background-color: rgba(0, 0, 0, .5);  
            transition: top 1s ease 0s;  
        }
        .box:hover p{
          top: 270px;
        }
    </style>
</head>
<body>
    <div class="box">
        <img src="images/duck.png" alt="">
        <p>这是一只小黄鸭</p>
    </div>
</body>
</html>


写回答

1回答

好帮手慕小李

2022-02-16

同学你好,代码可以实现效果,棒棒的!但是效果还可以稍微优化一下,比如上浮框如下:

https://img.mukewang.com/climg/620c597a09608b5204510408.jpg

优化建议:

https://img.mukewang.com/climg/620c59be095526a106520336.jpg

https://img.mukewang.com/climg/620c59ca0937f1d208330413.jpg

同学自己试试,祝学习愉快!

0

0 学习 · 17877 问题

查看课程