Reputation: 32143
I have a script (JS) running that will be making some different divs either visible or hidden. The problem I am having is that, even though the elements have a 'visibility' property of 'hidden', they still take up space. Is there a way I can hid the elements while also preventing them from taking up space?
I have access to jQuery as well, if that means anything...
Cheers,
DalexL
Upvotes: 0
Views: 73
Reputation: 17061
You could either us jQuery's hide()
function:
$("#sample").hide();
If you wanted to hide multiple divs, just add a class to all of them, and hide the entire class:
$(".sample").hide();
You could also use javascript like so:
function hidedivs() {
document.getElementById('sample').style.display='none';
}
But with that, you'd have to make one for each element. I'd recommend the above jquery.
More about hide()
here: http://api.jquery.com/hide
Upvotes: 1
Reputation: 22415
Try using display: none;
instead of visibility: hidden
;
JQuery's .hide()
method does this as well. You can display again using simply .show()
Upvotes: 1
Reputation: 43810
Use the display: none
css property
when you use visibility :hidden
the hidden element still occupies its height and width.
While display property make the element completely collapse.
Upvotes: 1