CSS是前端开发中必须掌握的技能之一,其中边框与背景是常用的属性之一。本文将介绍CSS的边框与背景属性以及它们的用途和示例。 边框属性 borderstyle `borderstyle`属性定义边...
CSS是前端开发中必须掌握的技能之一,其中边框与背景是常用的属性之一。本文将介绍CSS的边框与背景属性以及它们的用途和示例。
## 边框属性
### border-style
`border-style`属性定义边框的样式,有以下几种取值:
* `dotted`:点线边框;
* `dashed`:虚线边框;
* `solid`:实线边框;
* `double`:双线边框;
* `groove`:3D凹槽边框;
* `ridge`:3D强凸边框;
* `inset`:3D凸边框;
* `outset`:3D凹边框;
* `none`:无边框;
例如:
css
.box {
border-style: solid;
} css
.box {
border-width: 5px;
} css
.box {
border-color: #ff0000;
} css
.box {
border: 2px dashed #000;
} css
.box {
background-color: #eee;
} css
.box {
background-image: url('image.png');
} css
.box {
background-image: url('image.png');
background-repeat: no-repeat;
} css
.box {
background-image: url('image.png');
background-position: center top;
} css
.box {
background: #fff url('image.png') center top no-repeat;
}