以下为ChatGPT自动生成的解答,正确与否请自行判断。 也许你也可以从大家的发帖中找到想要的答案!
BFE.devAI解答 - 前端面试问题
168. What is the difference between `display:none` and `visibility:hidden`
display:none
will completely hide an element and remove it from the page flow, so it won't take up any space. However, visibility:hidden
will only hide the element, but it will still take up the space it occupies on the page. In other words, display:none
removes the element altogether, while visibility:hidden
hides it but preserves the space it occupies.