css的四種隱藏方式代碼詳解

來源:互聯網
上載者:User

1.opacity:0隻是把元素隱藏起來了 ,但是還是佔有布局,所以還是對布局有影響

<pclass="p1">snda:opacity:0隻是把元素隱藏起來了 ,但是還是佔有布局,所以還是對布局有影響</p><p>ppskdkad</p>


.p1{opacity:0;width:200px;height:200px;border:1pxsolidred;}

2.visibility:hidden還是只是把元素隱藏了,但是還是佔有布局

<pclass="p2">這是第二個p visibility:hidden還是只是把元素隱藏了,但是還是佔有布局</p><p>看看效果</p>
.p2{visibility:hidden;width:200px;height:200px;border:1pxsolidred;}



3.display:none不會影響到布局

<pclass="p3">這是第三個p display:none不會影響到布局</p><p>不信你看</p>
.p3{display:none;width:200px;height:200px;border:1pxsolidred;}

4.position:absolute不會影響到布局

<pclass="p4">這個是第四個p 我覺得也不會影響到布局 但是到底會不會 一起來看看吧 果然這個也不會影響到布局</p><p>看看</p>v
.p4{position:absolute;top:-9999px;left:-9999px;width:200px;height:200px;border:1pxsolidred;}

以上這四種隱藏方式大家學會了嗎?趕緊動手嘗試一下吧。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.