老师请检查,谢谢
来源: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属性添加过渡效果。
祝学习愉快~