CSS margin-right 是右邊距,又稱 CSS 右外邊距間隔屬性。
它屬於對象與對象之間的間距屬性。兩個並排的近鄰對象,只要對前者設定 margin-right 樣式,就能實現兩個盒子之間的間隔距離。
margin-right:20px
margin-right:-10px
右邊距後直接跟具體數值,可以為正也可以為負,平時多使用正數值。
span{margin-right:30px} 為 span 標籤盒子設定右邊距 30px。
div css 實例程式碼:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>margin-right實例 ThinkCSS</title>
<style>
.div1,.div2{float:left; width:200px; height:80px;}
.div1{border:1px solid #F00; margin-right:10px}
.div2{border:2px solid #00F}
</style>
</head>
<body>
<div class="div1"></div>
<div class="div2"></div>
</body>
</html>
截圖:

margin-right 右(外)邊距設置實例
透過以上案例可以看到,兩個 DIV 盒子之間的間距,可以使用 margin-right 或 margin-left 來設定間隔距離。