w3c/csswg-drafts
在 GitHub 查看[cssom-view] No browsers honor "the HTML body element" in `offsetTop`
Open
#584 创建于 2016年10月10日
Help Wantedcssom-view-1
仓库指标
- Star
- (3,546 star)
- PR 合并指标
- (平均合并 87天 7小时) (30 天内合并 24 个 PR)
描述
https://drafts.csswg.org/cssom-view/#dom-htmlelement-offsettop
If the element is the HTML body element or does not have any associated CSS layout box return zero and terminate this algorithm.
<html>
<body id=body></body>
<script>
var body = document.getElementById('body');
var innerBody = document.createElement('body');
body.appendChild(innerBody);
window.alert(innerBody.offsetTop);
window.alert(innerBody.offsetLeft);
</script>
</html>
At the time of writing, Safari, Chrome, and Firefox all output 0 and 0 for this.