個人收集(轉載)CSS中 display:none和visibility:hidden的區別

來源:互聯網
上載者:User

標籤:

visibility和display兩個屬性都有隱藏元素的功能,display:none和visibility:hidden的區別,簡單的總結一句話就是:visibility:hidden隱藏,但在瀏覽時保留位置;而display:none視為不存在,且不載入!

1、visibility:hidden--為隱藏的對象保留其物理空間HTML元素(對象)僅僅是在視覺上看不見(完全透明),而它所佔據的空間位置仍然存在。 2、display: none--不為被隱藏的對象保留其物理空間HTML元素(對象)的寬度、高度等各種屬性值都將“丟失”執行個體:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>無標題文檔</title></head><body><table>    <tr>   <td>    <table border="1">    <tr>     <td>第一行</td>    </tr>    <tr style="display:none">     <td>第二行</td>    </tr>    <tr>     <td>第三行</td>    </tr>    </table>   </td>   <td>    <table border="1">    <tr>     <td>第一行</td>    </tr>    <tr style="visibility:hidden">     <td>第二行</td>    </tr>    <tr>     <td>第三行</td>    </tr>    </table>   </td>  </tr>  <tr>   <td>style="display:none"</td>   <td>style="visibility:hidden"</td>  </tr></table></body></html>結果如下:

個人收集(轉載)CSS中 display:none和visibility:hidden的區別

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.