为什么 document.body.style.margin
如果
style="margin:[some] px"没有为 body 设置。
现在假设我想通过 div 的某些子元素使用 offsetParent.offsetLeft
css 属性来设置 body 的边距。默认情况下它给我 0px。好吧,如果 body 元素最初是默认的 0px 边距那么为什么我的 html 视觉元素在页面左侧显示有一些边距,结果为 8px。
body margin只有0px吗??
HTML:
<div>
<p>hello</p>
</div>
CSS:
div {
height:200px;
width:200px;
background:green;
border:2px solid green;
padding:10px 10px
}
p {
height:100px;
width:100px;
padding:10px 0 0 10px;
background:yellow
}
最佳答案
关于javascript - html 元素的意外边距,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17533334/