選單
×
   ❮     
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS R TYPESCRIPT ANGULAR GIT POSTGRESQL MONGODB ASP AI GO KOTLIN SASS VUE DSA GEN AI SCIPY AWS CYBERSECURITY DATA SCIENCE
     ❯   

W3.CSS 外邊距


w3-margin 類會在元素的四周新增 16px 的外邊距。


W3.CSS 外邊距類

W3.CSS 提供以下外邊距類

定義
w3-margin 為元素的四周新增 16px 的外邊距
w3-margin-top 為元素新增 16px 的頂部外邊距
w3-margin-right 為元素新增 16px 的右側外邊距
w3-margin-bottom 為元素新增 16px 的底部外邊距
w3-margin-left 為元素新增 16px 的左側外邊距
w3-section 為元素的頂部和底部新增 16px 的外邊距

外邊距

w3-margin 類會在元素的四周新增 16px 的外邊距

w3-margin 類會在元素的四周新增 16px 的外邊距。

示例

<div class="w3-container w3-margin">
  <p>我的四周都有 16px 的外邊距。</p>
</div>
自己試試 »

頂部外邊距

w3-margin-top 類為元素新增 16px 的頂部外邊距

w3-margin-top 類為元素新增 16px 的頂部外邊距。

示例

<div class="w3-container w3-margin-top">
  <p>我的頂部有 16px 的外邊距。</p>
</div>
自己試試 »


底部外邊距

w3-margin-bottom 類為元素新增 16px 的底部外邊距

w3-margin-bottom 類為元素新增 16px 的底部外邊距。

示例

<div class="w3-container w3-margin-bottom">
  <p>我的底部有 16px 的外邊距。</p>
</div>
自己試試 »

左側外邊距

w3-margin-left 類為元素新增 16px 的左側外邊距

w3-margin-left 類為元素新增 16px 的左側外邊距。

示例

<div class="w3-container w3-margin-left">
  <p>我的左側有 16px 的外邊距。</p>
</div>
自己試試 »

右側外邊距

w3-margin-right 類為元素新增 16px 的右側外邊距

w3-margin-right 類為元素新增 16px 的右側外邊距。

示例

<div class="w3-container w3-margin-right">
  <p>我的右側有 16px 的外邊距。</p>
</div>
自己試試 »

區塊

許多 HTML 元素預設沒有頂部或底部外邊距。這些元素會顯示為沒有間距。

我是藍色

我是綠色

w3-section 類可用於分隔元素。

它會為任何 HTML 元素新增16px 的頂部和底部外邊距

我是藍色

我是綠色

示例

<div class="w3-container w3-section w3-blue">
  <h1>我是藍色</h1>
</div>

<div class="w3-container w3-section w3-green">
  <h1>我是綠色</h1>
</div>
自己試試 »

×

聯絡銷售

如果您想將 W3Schools 服務用於教育機構、團隊或企業,請傳送電子郵件給我們
sales@w3schools.com

報告錯誤

如果您想報告錯誤,或想提出建議,請傳送電子郵件給我們
help@w3schools.com

W3Schools 經過最佳化,旨在方便學習和培訓。示例可能經過簡化,以提高閱讀和學習體驗。教程、參考資料和示例會不斷審查,以避免錯誤,但我們無法保證所有內容的完全正確性。使用 W3Schools 即表示您已閱讀並接受我們的使用條款Cookie 和隱私政策

版權所有 1999-2024 Refsnes Data。保留所有權利。W3Schools 由 W3.CSS 提供支援