我有以下div
CSS
- .description {
- color: #b4afaf;
- font-size: 10px;
- font-weight: normal;
- }
HTML
- <div class="description">Some text here </div>
然后我有一个元素的点击函数来隐藏上面的div:
- $('#target').click(function(){
- $(".description").hide();
- });
当我隐藏div,它会崩溃(停止占用任何空间)。这是搞乱我的页面的布局。
有没有办法我可以隐藏的div,但仍然占用它之前的空间?我不想改变字体颜色,因为它仍然可以选择。
谢谢
解决方法
使用
visibility css属性
能见度:
The visibility property specifies whether the Boxes generated by an
element are rendered.
- $(".description").css('visibility','hidden');
演示:Fiddle