主要区别就是
visibility:hidden 时在页面中仍旧占空间,而display:none不占空间。
display:none
Turns off the display of an element (it has no effect on layout);
all child elements also have their display turned off.
不显示该元素(该元素不影响布局,即不占位);所有子元素也不显示。
visibility:hidden
The box is invisible (fully transparent, nothing is drawn), but still affects layout. Descendants of the element will be visible if they have visibility:visible (this doesn‘t work in IE up to version 7).
该容器不可见(完全透明,不绘制),但仍然影响布局。如果后代(子孙)元素设置了 visibility:visible 样式将会显示。
时间: 2024-10-14 01:18:53