content内边距可以实现,为啥top外边距实现不了?
来源:3-5 编程练习
xzhou
2020-03-01 19:53:50
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style>
.content{
width:800px;
height:400px;
background-color: skyblue;
box-sizing: border-box;
}
.top{
width:400px;
height:200px;
background-color: yellow;
margin-left: 200px;
margin-top: 100px;
}
</style>
</head>
<body>
<div class="content">
<div class="top"></div>
</div>
</body>
</html>
1回答
好帮手慕酷酷
2020-03-02
同学你好,代码的整体思路不错,但还有一点小问题:
设置content内上边距为100px,应该使用padding-top设置100px。表示外面的大div与里面小div的距离,而不是设置top的上外边距具体如下:

如果我的回答解决了你的疑惑,请采纳!祝学习愉快!
相似问题