Does opacity:0 have exactly the same effect as visibility:hidden

前端 未结 9 1448
予麋鹿
予麋鹿 2020-11-22 11:53

If so, does it effectively deprecate the visibility property?

(I realize that Internet Explorer does not yet support this CSS2 property.)
Comparis

9条回答
  •  庸人自扰
    2020-11-22 12:27

    Here is a compilation of verified information from the various answers.

    Each of these CSS properties is unique. In addition to rendering an element not visible, they have the following additional effect(s):

    1. Collapses the space that the element would normally occupy
    2. Responds to events (e.g., click, keypress)
    3. Participates in the taborder
                         collapse events taborder
    opacity: 0              No     Yes     Yes
    visibility: hidden      No     No      No
    visibility: collapse   Yes*    No      No
    display: none          Yes     No      No
    
    * Yes inside a table element, otherwise No.
    

提交回复
热议问题