border-top-style
Baseline
Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
Thuộc tính border-top-style CSS đặt kiểu đường kẻ cho border phía trên của phần tử.
Note: Thông số kỹ thuật không định nghĩa cách các đường viền có kiểu khác nhau kết nối với nhau ở các góc.
Try it
border-top-style: none;
border-top-style: dotted;
border-top-style: dashed;
border-top-style: solid;
border-top-style: groove;
border-top-style: inset;
<section id="default-example">
<div class="transition-all" id="example-element">
This is a box with a border around it.
</div>
</section>
#example-element {
background-color: #eeeeee;
color: black;
border: 0.75em solid;
padding: 0.75em;
width: 80%;
height: 100px;
}
body {
background-color: white;
}
Cú pháp
css
/* Giá trị từ khóa */
border-top-style: none;
border-top-style: hidden;
border-top-style: dotted;
border-top-style: dashed;
border-top-style: solid;
border-top-style: double;
border-top-style: groove;
border-top-style: ridge;
border-top-style: inset;
border-top-style: outset;
/* Giá trị toàn cục */
border-top-style: inherit;
border-top-style: initial;
border-top-style: revert;
border-top-style: revert-layer;
border-top-style: unset;
Thuộc tính border-top-style được chỉ định bằng một giá trị từ khóa <line-style> duy nhất.
Định nghĩa hình thức
| Initial value | none |
|---|---|
| Applies to | all elements. It also applies to ::first-letter. |
| Inherited | no |
| Computed value | as specified |
| Animation type | discrete |
Cú pháp hình thức
border-top-style =
<line-style>
<line-style> =
none |
hidden |
dotted |
dashed |
solid |
double |
groove |
ridge |
inset |
outset
Ví dụ
>Đặt border-top-style
HTML
html
<table>
<tbody>
<tr>
<td class="b1">none</td>
<td class="b2">hidden</td>
<td class="b3">dotted</td>
<td class="b4">dashed</td>
</tr>
<tr>
<td class="b5">solid</td>
<td class="b6">double</td>
<td class="b7">groove</td>
<td class="b8">ridge</td>
</tr>
<tr>
<td class="b9">inset</td>
<td class="b10">outset</td>
</tr>
</tbody>
</table>
CSS
css
/* Định nghĩa giao diện của bảng */
table {
border-width: 2px;
background-color: #52e385;
}
tr,
td {
padding: 3px;
}
/* Các lớp ví dụ border-top-style */
.b1 {
border-top-style: none;
}
.b2 {
border-top-style: hidden;
}
.b3 {
border-top-style: dotted;
}
.b4 {
border-top-style: dashed;
}
.b5 {
border-top-style: solid;
}
.b6 {
border-top-style: double;
}
.b7 {
border-top-style: groove;
}
.b8 {
border-top-style: ridge;
}
.b9 {
border-top-style: inset;
}
.b10 {
border-top-style: outset;
}
Kết quả
Thông số kỹ thuật
| Specification |
|---|
| CSS Backgrounds and Borders Module Level 3> # border-style> |
Khả năng tương thích trình duyệt
Xem thêm
- Các thuộc tính đường viền liên quan đến kiểu:
border-left-style,border-right-style,border-bottom-style, vàborder-style. - Các thuộc tính liên quan đến đường viền phía trên:
border-top,border-top-color, vàborder-top-width.