请老师检查谢谢~
来源:2-9 自由编程
Dreamboat丶C
2022-02-19 10:41:32
<!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 {
position: relative;
width: 300px;
height: 240px;
overflow: hidden;
margin: 0 auto;
}
.duck-img {
position: absolute;
left: 50%;
margin-left: -150px;
width: 300px;
height: 240px;
}
.duck {
position: absolute;
width: 300px;
height: 30px;
line-height: 30px;
color: white;
background-color: rgba(0,0,0,0.5);
left: 50%;
margin-left: -150px;
top: 240px;
transition: top 1s linear 0s;
}
div:hover p {
top: 210px;
}
</style>
</head>
<body>
<div>
<img class="duck-img" src="img/duck.png" alt="">
<p class="duck">这是一只小黄鸭</p>
</div>
</body>
</html>
1回答
好帮手慕星星
2022-02-19
同学你好,代码实现效果很棒。继续加油,祝学习愉快!