javascript-tutorial / javascript-tutorial/en.javascript.info
Error description with element hidden check in "Element size and scrolling"
- 主要语言
- HTML
- 星标
- 25.5k
- 派生
- 4k
- PR 合并指标
- 30 天内没有已合并 PR
描述
The tutorial said:
> Geometry properties are calculated only for displayed elements.
>
> If an element (or any of its ancestors) has display:none or is not in the document, then all geometry properties are zero (or null for offsetParent).
>
> For example, offsetParent is null, and offsetWidth, offsetHeight are 0 when we created an element, but haven’t inserted it into the document yet, or it (or it’s ancestor) has display:none.
>
> We can use this to check if an element is hidden, like this:
>
> ```js
> function isHidden(elem) {
> return !elem.offsetWidth && !elem.offsetHeight;
> }
> ```
But, what if the hidden element is hidden by setting the `width` to `0`, not the `height`? 😀
贡献指南
这个仓库没有索引到贡献指南
调研方向
从“元素大小和滚动”教程部分开始,审阅引用的几何属性说明和 isHidden 示例。明确当元素的宽度为零时该示例的行为,并确保最终文本准确解释隐藏元素检查。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- javascript
- 领域
- documentation
- Issue 类型
- 文档
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 45/100