CSS 边框属性允许您指定样式, 元素边框的宽度和颜色。
我四面八方都有边界。
我有一个红色的底边框。
我有圆形边框。
class="w3-codespan">border-style
属性指定要显示的边框类型。
允许使用以下值:
class="w3-codespan">dotted
- 定义虚线边框
class="w3-codespan">solid
- 定义实心边框
class="w3-codespan">double
- 定义双边框
class="w3-codespan">groove
- 定义 3D 凹槽边框。效果取决于边框颜色值
class="w3-codespan">ridge
- 定义 3D 脊状边框。效果取决于边框颜色值
class="w3-codespan">inset
- 定义 3D 插入边框。效果取决于边框颜色值
class="w3-codespan">outset
- 定义 3D 起始边框。效果取决于边框颜色值
class="w3-codespan">none
- 不定义边框
class="w3-codespan">hidden
- 定义隐藏边框
class="w3-codespan">border-style
属性可以有 1 到 4 个值(例如 上边框、右边框、下边框和左边框)。
不同边框样式的演示:
p.dotted {border-style: dotted;}
p.dashed
{border-style: dashed;}
p.solid {border-style: solid;}
p.double
{border-style: double;}
p.groove {border-style: groove;}
p.ridge
{border-style: ridge;}
p.inset {border-style: inset;}
p.outset
{border-style: outset;}
p.none {border-style: none;}
p.hidden {border-style: hidden;}
p.mix {border-style: dotted dashed solid double;}
结果 :
A dotted border.
A dashed border.
A solid border.
A double border.
A groove border. The effect depends on the border-color value.
A ridge border. The effect depends on the border-color value.
An inset border. The effect depends on the border-color value.
An outset border. The effect depends on the border-color value.
No border.
A mixed border.
自己尝试一下→
<!DOCTYPE html>
<html>
<head>
<style>
p.dotted {border-style: dotted;}
p.dashed {border-style: dashed;}
p.solid {border-style: solid;}
p.double {border-style: double;}
p.groove {border-style: groove;}
p.ridge {border-style: ridge;}
p.inset {border-style: inset;}
p.outset {border-style: outset;}
p.none {border-style: none;}
p.hidden {border-style: hidden;}
p.mix {border-style: dotted dashed solid double;}
</style>
</head>
<body>
<h2>The border-style Property</h2>
<p>This property specifies what kind of border to display:</p>
<p class="dotted">A dotted border.</p>
<p class="dashed">A dashed border.</p>
<p class="solid">A solid border.</p>
<p class="double">A double border.</p>
<p class="groove">A groove border.</p>
<p class="ridge">A ridge border.</p>
<p class="inset">An inset border.</p>
<p class="outset">An outset border.</p>
<p class="none">No border.</p>
<p class="hidden">A hidden border.</p>
<p class="mix">A mixed border.</p>
</body>
</html>
注意:其他 CSS 边框属性(您将在下一章中了解更多)都不会产生任何效果,除非 class="w3-codespan">border-style
属性已设置!