一 border定義:
1 元素的邊框 (border) 是圍繞元素 內容(width+height) 和 內邊距(padding)的一條或多條線。
2 邊框與背景
CSS 規範指出,邊框繪製在“元素的背景之上”。這很重要,因爲有些邊框是“間斷的”(例如,點線邊框或虛線框),元素的背景應當出現在邊框的可見部分之間。
CSS2 指出背景只延伸到內邊距,而不是邊框。後來 CSS2.1 進行了更正:元素的背景是內容、內邊距和邊框區的背景。大多數瀏覽器都遵循 CSS2.1 定義,不過一些較老的瀏覽器可能會有不同的表現。
二 明確這些細小的定義之後,簡單寫個demo走下效果:
.one {
width: 800px;
height: 400px;
border:dotted green 50px;
}
<body>
<div class="one"></div>
</body>'
.one {
width: 800px;
height: 400px;
border:dotted green 50px;
background-color:pink;
}
背景色會填充到border 區域。
.one {
width: 800px;
height: 400px;
border:dotted green 50px;
background: url(vb.jpg) ;
}