过渡与动画2-9自由编程作业提交
来源:2-9 自由编程
慕越秀工地
2022-04-18 11:49:18
老师你好,这个作业我无法做到和演示效果一样,文字的背景向上滑动的效果。请赐教。
<!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;
}
.box {
width: 300px;
height: 240px;
overflow:hidden;
position: relative;
}
.box p {
position: absolute;
top:210px;
width: 290px;
height: 30px;
line-height: 30px;
padding-left:10px;
color: white;
background-color: rgba(0,0,0,.5);
opacity: 0;
transition: opacity 1s linear 0s;
}
.box:hover p {
opacity: 1;
}
</style>
</head>
<body>
<div class="box">
<img src="images/duck.png" alt="">
<p>这是一只小黄鸭</p>
</div>
</body>
</html>1回答
同学你好,这个需要结合定位的top值来实现,鼠标悬停的时候,改变top值即可,参考如下:

祝学习愉快!
相似问题