如何在單個宣告中設定 CSS 間距屬性?


 間距 屬性定義 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>

更新日期: 2020 年 2 月 3 日

238 次瀏覽

開啟你的 職業生涯

完成課程即可獲得認證

入門
廣告
© . All rights reserved.