麻烦老师检查 有无优化的地方
来源:2-9 自由编程
dww1
2021-10-17 15:43:39
<style> *{ margin: 0; padding: 0; } .box{ width: 300px; height: 224px; overflow: hidden; margin: 40px auto; position: relative; } .box img{ width: 280px; height: 224px; } .box p{ position: absolute; top: 224px; width: 270px; height: 60px; padding-left: 10px; line-height: 60px; color: white; background-color: rgba(0, 0, 0, .4); transition: top 1s ease-in-out 0s; } .box:hover p{ top:164px; } </style>
<div class="box"> <img src="images/duck.png" alt=""> <p>这是一只小黄鸭</p> </div>
1回答
好帮手慕然然
2021-10-17
同学你好,代码实现效果基本没问题,建议父盒子box的宽度与内部图片img的宽度保持一致即可,如图
祝学习愉快!
相似问题