为了账号安全,请及时绑定邮箱和手机立即绑定

为什么big添加浮动后,small中margin-top是相对于big的,而不是body的

为什么big添加浮动后,small中margin-top是相对于big的,而不是body的

Efficiency90 2017-03-11 14:42:38
<!DOCTYPE html><html><head>    <meta charset="UTF-8">    <title>设置背景渐变</title>    <style type="text/css">        .big{            width: 300px;            height: 300px;            background-color: red;            margin-top:100px;            float: left;        }        .small{            width: 100px;            height: 100px;            background-color: blue;            margin-top:10px;        }    </style></head><body><div class="big">    <div class="small"></div></div></body></html>
查看完整描述

2 回答

?
ripplexaz

TA贡献3条经验 获得超0个赞

联系去看下cssfloat 和cssposition这两门课,里面讲的很详细
查看完整回答
反对 回复 2017-03-22
?
Love__

TA贡献5条经验 获得超0个赞

因为你类为big的div包含着small,small相对于父级

查看完整回答
反对 回复 2017-03-11
  • 2 回答
  • 1 关注
  • 1232 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信