各位资深大佬们,小白想请教一个问题,css盒子模型中说当指定外边距(margin)为负值时
,**整个盒子将向指定负值方向的相反方向移动**,以此产生盒子重叠效果。为什么是相反方向啊?如果我定义margin-top:-15px; 难道盒子向下移动???,正常来说,如果是
margin-top:15px;这时不是盒子向下移动吗???
(不知道我表达清楚了没=^=)
各位资深大佬们,小白想请教一个问题,css盒子模型中说当指定外边距(margin)为负值时
,**整个盒子将向指定负值方向的相反方向移动**,以此产生盒子重叠效果。为什么是相反方向啊?如果我定义margin-top:-15px; 难道盒子向下移动???,正常来说,如果是
margin-top:15px;这时不是盒子向下移动吗???
(不知道我表达清楚了没=^=)
收起
对啊,正常为正值margin-top:15px时盒子是向下移动。为负值margin-top:-15px时移动方向则与正值时相反,也就是向上移动啊
你自己写个例子对比一下不就知道了
<!doctype html>
<html>
<head>
<meta charset="utf-8">
</head>
<body style="padding-top: 50px;">
<div style="float: left; margin-top: 15px; background: #999">margin-top:15px</div>
<div style="float: left; margin-top: 0px; background: #999">margin-top:0px</div>
<div style="float: left; margin-top: -15px; background: #999">margin-top:-15px</div>
</body>
</html>
报告相同问题?