Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS: Is a hidden object clickable?

If the visibility property of the style of an HTML element is set to hidden, is it still clickable?

When the display property is set to none, the element is not even part of the DOM tree, so that is not a problem. But I was wondering if a hidden element still responds to mouse events.

like image 911
euphoria83 Avatar asked Apr 14 '11 06:04

euphoria83


People also ask

How do I show hidden content in CSS?

You can hide an element in CSS using the CSS properties display: none or visibility: hidden . display: none removes the entire element from the page and mat affect the layout of the page. visibility: hidden hides the element while keeping the space the same.

What is the opposite of hidden CSS?

The opposite of visibility: hidden is visibility: visible .

What is the difference between display none and visibility hidden?

display:none means that the tag in question will not appear on the page at all (although you can still interact with it through the dom). There will be no space allocated for it between the other tags. visibility:hidden means that unlike display:none, the tag is not visible, but space is allocated for it on the page.

Which CSS property is used to hide an element?

The visibility CSS property shows or hides an element without changing the layout of a document.


1 Answers

With display: none it is still part of the DOM. It just isn't rendered in the viewport.

As for clicks on elements with visibility: hidden, the events are not fired.

jsFiddle.

$('div').click(function() {      alert('Hello')  });
div {      width: 100%;      height: 100%;      visibility: hidden;   }
<div>abc</div>
like image 93
alex Avatar answered Nov 09 '22 08:11

alex