.dashed{ border-style: dashed; } .dotted{ border-style: dotted; } .solid{ border-style: solid; }
其中,点线是由点和线交替组成,可通过设置样式为dotted来实现。
实线即为完整的一条线,可通过设置样式为solid来实现。
虚线是由若干个短线组成的,可通过设置样式为dashed来实现。在设置虚线时,还可以通过border-width调整线条的粗细,border-color设置线条颜色。
.dashed{ border-style: dashed; border-width: 2px; border-color: #ccc; }
除此之外,还可以通过border-top-style, border-right-style, border-bottom-style和border-left-style来分别设置元素上、右、下、左四个方向的线条样式。
通过使用CSS提供的三种线条样式,可以让网页更加美观、整洁,提高用户体验。