javascript-tutorial / javascript-tutorial/en.javascript.info

Error description with element hidden check in "Element size and scrolling"

未關閉
#1,955 4 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
tell your opinion
主要語言
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

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。