老师请检查,谢谢

来源:2-9 自由编程

慕的地7233660

2022-03-27 13:42:50

相关代码:
 <style>
        *{
            margin: 0;
            padding: 0;
        }
        div{
            width: 300px;
            height: 240px;
            margin:50px auto;
            overflow: hidden;
            position: relative;
        }
        img{
            width: 300px;
            height: 240px;
        }
        p{
            background-color: rgba(0,0,0,.2);
            color: white;
            width: 300px;
            height: 40px;
            line-height: 40px;
            bottom: 0px;
            position: absolute;
            opacity: 0;
        }
        div:hover p{
            opacity: 1;
        }
    </style>
</head>
<body>
    <div>
        <img src="images/duck.png" alt="">
        <p>这是一个小黄鸭</p>
    </div>


写回答

1回答

好帮手慕慕子

2022-03-27

同学你好,鼠标移入图片,直接显示文字,并没有从下到上的一个过渡显示效果。

建议修改:去掉opacity属性,通过bottom调整文字位置,针对bottom属性添加过渡效果。

https://img.mukewang.com/climg/6240036009fb707806510504.jpg

祝学习愉快~

0

0 学习 · 17877 问题

查看课程