老师检查下
来源:2-5 编程练习
罗杰明
2020-01-07 15:30:04
<html>
<head>
<meta charset="text/css">
<title>网站测试</title>
<style class="text/css">
.div1{
background-color:red;
width:500px;
height:500px;
margin-left:100px;
margin-top:100px;
position:relative;
}
.div2{
background-color:blue;
width:250px;
height:250px;
position:absolute;
top:130px;
left:120px;
}
</style>
</head>
<body>
<div class="div1">
<div class="div2"></div>
</div>
</body>
</html>
1回答
同学你好!
整体完成不错~
但是你的div2并没有位于div1的正中央
你的div1的宽度和高度是500px
div2的宽度和高度是250px,因此还剩下250px,因此left和top可以设置为250的一半,125px
如果我的回答解决了你的疑惑,请采纳,祝学习愉快~