2-7编程练习
来源:2-7 编程练习
慕码人5382834
2020-09-15 16:49:05
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
*{
padding: 0;
margin: 0;
}
.blue{
width: 100px;
height: 100px;
background: blue;
position:relative;
top:50px;
left:50px;
}
.red{
width: 100px;
height: 100px;
background: red;
}
</style>
</head>
<body>
<div class="blue"></div>
<div class="red"></div>
</body>
</html>
请问上面的代码是否有误,这里的top和left都是相对于蓝色元素本身的向上50px,向左50px对吗?
谢谢。
1回答
好帮手慕糖
2020-09-15
同学你好,代码是对的。但是这里不是相对于本身向左、向上哦。是相对于原来的本身向右、向下了。可以结合效果再查看下。
祝学习愉快~
相似问题