freeCodeCamp/guide/chinese/certifications/responsive-web-design/basic-css/adjust-the-margin-of-an-ele.../index.md

41 lines
770 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

---
title: Adjust the Margin of an Element
localeTitle: 调整元素的边距
---
## 调整元素的边距
调整`Element`的`Margin`意味着增加或减少元素边框与周围元素之间的间距。
•以像素为单位( `px` )以正整数和负整数调整边距。
•可以从所有方向(顶部,底部,左侧,右侧)创建边距。
这是它如何编写的一个例子:
```css
margin: 20px;
```
您可以通过更改数值轻松更改或调整`Element`的`Margin`
**之前**
保证金: `20` px;
**之后**
保证金: `50` px;
您还可以创建一个具有您将重复使用的`margin`的自定义`class` 。
```css
.style-margin {
margin: 20px;
}
```
```html
<h2 class="style-margin">Example</h2>
```