我有一個標準
<details>
<summary>
Text
</summary>
</details>
和<div >同一頁面上的其他地方(details完全之外)。如何隱藏div時間details[open],例如通過設定.something {display: none;}?
我試過
details[open] > .something {
display: none;
}
有和沒有>,但它沒有做任何事情。
我也對 JS 持開放態度,但我希望這能在 css 中作業。
uj5u.com熱心網友回復:
您可以使用兄弟運算子。但請注意 CSS 不能向上或反向遍歷。
details[open] ~ .nested .something,
details[open] .something {
display: none;
}
<details>
<summary>Details</summary>
Something small enough to escape casual notice.
</details>
<div class="something">Something something, open details.</div>
<div class="nested">
<p>Let's try to target the below too.</p>
<p class="something">You won't see this if details is open.</p>
</div>
TBH,這有點解釋它:
![詳細資訊時隱藏另一個元素[打開]](https://img.uj5u.com/2022/05/20/a04f6fda1a684b2e9ca687fe958a6c36.png)
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/478188.html
