请老师检查作业
来源:2-9 自由编程
鱼档卖鱼
2021-12-14 11:01:03
<!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 {
width: 300px;
height: 240px;
margin: 20px auto;
position: relative;
}
div img {
width: 300px;
height: 240px;
}
div p {
width: 290px;
height: 35px;
background-color: rgba(102, 93, 93, 0.5);
color: white;
padding-left: 10px;
line-height: 35px;
position: absolute;
bottom: -40px;
transition: bottom 1s ease 0s;
opacity: 0;
}
div:hover p {
position: absolute;
bottom: 0;
opacity: 1;
}
</style>
</head>
<body>
<div>
<img src="images/duck.png" alt="">
<p>这是一只小黄鸭</p>
</div>
</body>
</html>
1回答
好帮手慕慕子
2021-12-14
同学你好,思路是对的,建议优化:给div添加overflow:hidden;属性,效果会更美观,如下:
祝学习愉快~