老师这样实现可以吗?
来源:2-14 编程练习
qq_慕前端5127026
2019-10-28 21:28:34
<!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;
bottom:0;
right:0;
left:0;
margin:0 auto;
/*此处写代码*/
}
.out{
width: 100%;
height: 2000px;
background-color: #abcdef;
}
</style>
</head>
<body>
<div class="out">
<div class="test"></div>
</div>
</body>
</html>
1回答
好帮手慕粉
2019-10-29
同学你好,代码的大致效果已经实现了,但是跟我们练习要求的不太符合哦:
中间盒子test的水平居中需要通过left定位来实现,而非margin:0 auto哦,另外同学在设置定位的时候,top和bottom、left和right只设置其中一个哦:
希望我的回答能够帮助到你,望采纳,祝学习愉快!
相似问题