请老师检查
来源:2-9 自由编程
陈淑雯
2022-03-25 11:21:23
相关代码:
<!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;
overflow:hidden;
margin:40px auto;
position:relative;
}
.box img{
width:300px;
height:240px;
}
.box p{
position:absolute;
width:290px;
height: 50px;
line-height:50px;
color:white;
bottom: 0;
padding-left: 10px;
background-color: rgba(0,0,0,.5);
opacity:0;
transition:opacity 1s ease 0s;
}
.box:hover p{
opacity:1;
}
</style>
</head>
<body>
<div class="box">
<img src="imagess/duck.png" alt="">
<p>这是一支小黄鸭</p>
</div>
</body>
</html>1回答
好帮手慕星星
2022-03-25
同学你好,opacity属性过渡效果实现可以。
建议:练习中要求实现向上滑动效果,可以改变定位的值,参考

祝学习愉快!
相似问题