When opacity=0,visibility=hidden,display=none in CSS, what is the difference between the three?
Referring to StackOverflow's blog, we found the difference as follows:
Here are a compilation of verified information from the various answers.
Each of the these CSS properties is in fact unique. In addition to rendering a element not visible, they has the following additional effect (s):
- collapses the space that element would normally occupy
- Responds to events (e.g., click, KeyPress)
- Participates in the taborder
Collapse Events taborderopacity:0 no Yes yesvisibility:hidden no no novisibility: Collapse * no nodisplay:none Yes no no* yes inside a TABLE element, otherwise No.
---objects with Visibility:hidden still has shape, they just arent visible. Opacity zero elements can still is clicked and react to other events.
The summary is as follows:
1 opacity=0, the element is hidden, but does not change the page layout, and if the element has already bound some events, such as the Click event, then clicking on that area can also trigger the Click event
2 Visibility=hidden, the element is hidden, but does not change the page layout, but does not trigger an event that the element has already bound
3 Display=none, hide the element, and will change the layout of the page, it can be understood to delete the element in the page.
Reference:
Http://www.cnblogs.com/simonbaker/p/3570844.html
Http://stackoverflow.com/questions/272360/does-opacity0-have-exactly-the-same-effect-as-visibilityhidden
The difference between css:opacity:0,visibility:hidden,display:none