这样做对吗?
来源:2-14 编程练习
weixin_慕工程5378897
2021-04-21 16:07:37
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
*{
margin: 0;
padding:0;
}
.test{
width: 800px;
height: 100px;
background: red;
/*此处写代码*/
position:fixed;
top: 0;
left: 0;
bottom:0;
right: 0;
margin: 0 auto;
}
.out{
width: 100%;
height: 2000px;
background-color: #abcdef;
position: relative;
}
</style>
</head>
<body>
<div class="out">
<div class="test"></div>
</div>
</body>
</html>
1回答
好帮手慕然然
2021-04-21
同学你好,代码实现效果是对的,建议同学再尝试按照任务提示中提示的方法,来完成红色盒子水平居中的效果,参考代码如下:
祝学习愉快!