老师看看我的小黄鸭代码写的是否正确 效果怎么样
来源:2-9 自由编程
幕布斯0094879
2020-11-25 19:58:45
# 具体遇到的问题
# 报错信息的截图
# 相关课程内容截图
# 尝试过的解决思路和结果
# 粘贴全部相关代码,切记添加代码注释(请勿截图)
在这里输入代码,可通过选择【代码语言】突出显示
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style type="text/css">
* {
padding: 0;
margin: 0;
}
ul {
list-style: none;
}
.box {
width: 300px;
height: 240px;
margin: 0 auto;
overflow: hidden;
}
.box ul li{
height: 240px;
position: relative;
}
.box .title{
position: absolute;
bottom: -30px;
left: 0px;
padding-left: 10px;
width: 290px;
height: 30px;
background-color: rgba(0, 0, 0, .5);
line-height: 30px;
transition: all 0.2s linear 0s;
}
.box:hover .title{
bottom: 0;
left: 0;
color: #fff;
}
</style>
</head>
<body>
<div class="box">
<ul>
<li>
<img src="img/duck.png" alt="小黄鸭">
<div class="title">我是一只小黄鸭 只会嘎嘎嘎嘎嘎嘎嘎</div>
</li>
</ul>
</div>
</body>
</html>
1回答
同学你好,效果实现了哦,不过html中的代码可以再优化一下,因为这道练习题中没有过多的布局,建议直接使用div标签包裹img标签和div标签,参考如下:
祝学习愉快!
相似问题