海量收录 · 12,310+ 源码 / 模板 / 插件 / 教程,付款后立即下载 开通会员享折扣| 我的订单| 客服 QQ 923457156
前端开发教程

CSS 中 margin 属性的使用

2025-01-14 39 次浏览 免费资源

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 属性的使用的详细内容,更多请关注双恒网络其它相关文章!

免费下载无需付费,点击即可获取
去下载