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

子元素的margin为负值,就改变继承过来的width值,是什么原理?

子元素的margin为负值,就改变继承过来的width值,是什么原理?

梵蒂冈之花 2018-11-01 14:19:59
<div style="width:700px;overflow:hidden;" class="parent"><div style="background:yellow;margin-left:-20px;overflow:hidden;" class="son">    <div style="float:left;width:100px;height:300px;border:1px solid red;"></div>    <div style="float:left;width:100px;height:300px;border:1px solid pink;"></div>    <div style="float:left;width:100px;height:300px;border:1px solid black;"></div></div>以上代码中.parent是父元素,设置了width:700px;子元素.son继承过来的时候,应该是700px,但是子元素.son设置了margin-top:-20px;之后,.son的width就变成了720px,当子元素.son设置了margin-top:20px;则.son的width就变成了680px?是什么原理
查看完整描述

1 回答

  • 1 回答
  • 0 关注
  • 583 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号