首頁  >  文章  >  web前端  >  CSS 中 margin 屬性的使用

CSS 中 margin 屬性的使用

WBOY
WBOY轉載
2023-08-31 21:25:111040瀏覽

CSS 中 margin 属性的使用

margin 屬性定義 HTML 元素周圍的空間。可以使用負值來重疊內容。它指定一個簡寫屬性,用於在一個聲明中設定邊距屬性。

範例

您可以嘗試執行以下程式碼來設定邊距 -

<html>
   <head>
   </head>
   <body>
      <p style = "margin: 20px; border:2px solid yellow;">
         All four margins will be 20px
      </p>
      <p style = "margin: 15px 4% -10px; border:2px solid red;">
         Top margin will be 15px, left and right margin will be 4% of the total width of the document, bottom margin will be -10px
      </p>
   </body>
</html>

以上是CSS 中 margin 屬性的使用的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文轉載於:tutorialspoint.com。如有侵權,請聯絡admin@php.cn刪除