CSS的display屬性

來源:互聯網
上載者:User

標籤:style   class   blog   code   java   http   

網頁設計中最常用的標籤p、div、h1-h6(預設為區塊層級元素),span(預設為內嵌元素)

1、把元素顯示為內嵌元素和把元素顯示為區塊層級元素

<style type="text/css">    div{ display:inline; background:red;}/*區塊元素將轉換為內嵌元素*/    span{ display:block; background:green;}/*將內嵌元素轉換為區塊元素*/</style></head><body>    <div>我是div區塊層級元素</div>    <span>我是span內嵌元素</span></body>

 

 

 

2、設定元素不可見和設定元素為inline-block

<style type="text/css">    div{ display:none; background:red;}/*將元素設定為不可見*/    span{ display:inline-block; background:green;}/*還是內嵌元素 跟inline沒什麼區別,只有一點區別就是會自動加上一些邊距*/    h1{ display:inline-block; background:blue;}</style></head><body>    <div>我是div區塊層級元素</div>    <span>我是span內嵌元素</span>    <h1>fasdfsadf</h1></body>

 

 

聯繫我們

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