標籤:移動 可見 round pad tom 自動 一個 bsp otto
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>postion</title>
<style>
.box1{
width:200px;
height:200px;
background: greenyellow;
/*設定邊框*/
border:3px red solid;
/*設定內邊距*/
padding: 20px;
/*
*外邊距margin:指的是當前的盒子與其他盒子之間的距離
* 它不會影響盒子課可見框的大小,而是會影響盒子的位置
*特性:
* 1. 4個方向
* margin-top:
margin-right:
margin-bottom:
margin-left:
2.由於頁面中的元素都是靠左靠上位置擺放的
所以注意:當我們設定上和左外邊距時,會導致盒子自身位置的發生改變
當我們設定下和右外邊距時,會改變其他盒子的位置
3.可以設定 負值,負值——反方向移動
4.可以設定auto(自動)
一般只設定給水平方向,置中顯示
原因:
只指定:
1)水平方向為auto——————最大值
2)垂直方向為auto——————0
5.margin
*/
/*margin-top:-100px;
margin-right: 100px;
margin-bottom: 100px;*/
margin: 0 auto;/*水平置中*/
}
.box3{
width:200px;
height:200px;
background: blue;
}
/*建立一個子項目box2來佔滿box1*/
.box2{
height:100px;
width:100px;
background: yellow;
margin-left: 120px;
}
</style>
</head>
<body>
<div class="box1">
<div class="box2">我是box2</div>
</div>
<div class="box3">我是box3</div>
</body>
</html>
盒模型——外邊距