您的位置:首页 > HTML+CSS > css外边距margin是什么

css外边距margin是什么

来源:https://www.py.cn/web/css/29804.html 热度:481   更新时间:2022-08-06

文章导读:使用说明1、用来增加元素间距的,外边距跟边框一样,分为上、右、下、左4个方向的边距。2、margin可以沿着四个不同的方向(top,right,bottom,left)添加,所以在深入研究示例和用例之前,一定要阐明一些基本概念,这一点非常重。

使用说明

1、用来增加元素间距的,外边距跟边框一样,分为上、右、下、左4个方向的边距。

2、margin可以沿着四个不同的方向(top,right,bottom,left)添加,所以在深入研究示例和用例之前,一定要阐明一些基本概念,这一点非常重要。

实例


div{
width: 200px;
height: 200px;
}
.box1{
background: red;

margin-bottom: 20px;

//margin-bottom: 20px 50px;

//margin: auto;

//margin-top: -100px;
}
.box2{
background: blue;
}
 

以上就是css外边距margin的介绍,希望对大家有所帮助。