The use of margin property in CSS

WBOY
Release: 2023-08-31 21:25:11
forward
1038 people have browsed it

CSS 中 margin 属性的使用

margin attribute defines the space around an HTML element. Negative values ​​can be used to overlap content. It specifies a shorthand property for setting margin properties in a declaration.

Example

You can try running the following code to set the margins -

<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>
Copy after login

The above is the detailed content of The use of margin property in CSS. For more information, please follow other related articles on the PHP Chinese website!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!