Skip to content

Instantly share code, notes, and snippets.

@nishinoshake
Created January 25, 2016 13:43
Show Gist options
  • Save nishinoshake/081749eb62bd3bbf316a to your computer and use it in GitHub Desktop.
Save nishinoshake/081749eb62bd3bbf316a to your computer and use it in GitHub Desktop.
Visibility:hiddenの不思議
visibility: hiddenはレイアウトへの影響を残す。 具体的には次の3つ。
・要素の表示領域を残す
 「要素が生成するボックスのみ残り、要素自体は無くなる」と考えると分かりやすい
・要素の表示域が空白になる。
 クリックなどのマウスイベントを受け付けなくなる。
・子孫要素を表示可
 visibility: visibleを指定することで、指定の子孫要素以下を可視化できる。
 他の要素への影響を残す
 
marginやfloatなども有効なままで、単に空白を残すだけではない
これを利用して、疑似要素と合わせたclearfixがよく使われていた
参考
http://7cc.hatenadiary.jp/entry/visibility-display
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment