html隐藏元素

时间:2022-12-21 16:16:32
  1. <body>
  2. <div>display:元素的位置不被占用</div>
  3. <div id="div1" style="display:block;">DIV 1</div>
  4. <div id="div2" style="display:none;">DIV 2</div>
  5. <hr>
  6. <div>visibility:元素的位置仍被占用</div>
  7. <div id="div3" style="visibility:visible;">DIV 3</div>
  8. <div id="div4" style="visibility:hidden;">DIV 4</div>
  9. </body>

总结

display元素位置不被占用(不管是否被隐藏)

visibility元素位置被占用(不管是否被隐藏)

  1. 原文网址:https://blog.csdn.net/qq_35792598/article/details/76572595