一 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) ;
}