25 lines
670 B
Markdown
25 lines
670 B
Markdown
|
---
|
||
|
title: Add a Negative Margin to an Element
|
||
|
localeTitle: 向元素添加负边距
|
||
|
---
|
||
|
## 向元素添加负边距
|
||
|
|
||
|
边距是元素边框与页面上其他元素之间的间距。
|
||
|
|
||
|
•顶部,右侧,底部和左侧有间距。
|
||
|
|
||
|
•数字以[css为单位](https://www.tutorialspoint.com/css/css_measurement_units.htm)
|
||
|
|
||
|
例如,要将元素的边距调整为负值,您可以使用:
|
||
|
|
||
|
```css
|
||
|
.example {
|
||
|
margin: -10px;
|
||
|
}
|
||
|
```
|
||
|
|
||
|
**要调整单个元素的填充,请**使用: 填充: `-10` px;
|
||
|
|
||
|
[您可以在此处找到有关负边距的更多信息](https://www.smashingmagazine.com/2009/07/the-definitive-guide-to-using-negative-margins/)
|
||
|
|
||
|
祝你好运!
|