border-left-width
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-left-width trong CSS đặt độ rộng cho đường viền phía trái của một phần tử.
Try it
border-left-width: thick;
border-left-width: 2em;
border-left-width: 4px;
border-left-width: 2ex;
border-left-width: 0;
<section class="default-example" 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: palegreen;
color: black;
border: 0 solid crimson;
padding: 0.75em;
width: 80%;
height: 100px;
}
Cú pháp
css
/* Giá trị từ khóa */
border-left-width: thin;
border-left-width: medium;
border-left-width: thick;
/* Giá trị <length> */
border-left-width: 10em;
border-left-width: 3vmax;
border-left-width: 6px;
/* Từ khóa toàn cục */
border-left-width: inherit;
border-left-width: initial;
border-left-width: revert;
border-left-width: revert-layer;
border-left-width: unset;
Giá trị
<line-width>-
Xác định độ rộng của đường viền, có thể là giá trị
<length>không âm tường minh hoặc một từ khóa. Nếu là từ khóa, phải là một trong các giá trị sau:thin- Tương đương
1px.
- Tương đương
medium- Tương đương
3px.
- Tương đương
thick- Tương đương
5px.
- Tương đương
Định nghĩa hình thức
| Initial value | medium |
|---|---|
| Applies to | all elements. It also applies to ::first-letter. |
| Inherited | no |
| Computed value | the absolute length or 0 if border-left-style is none or hidden |
| Animation type | a length |
Cú pháp hình thức
border-left-width =
<line-width>
<line-width> =
<length [0,∞]> |
hairline |
thin |
medium |
thick
Ví dụ
>So sánh các độ rộng đường viền
HTML
html
<div>Element 1</div>
<div>Element 2</div>
CSS
css
div {
border: 1px solid red;
margin: 1em 0;
}
div:nth-child(1) {
border-left-width: thick;
}
div:nth-child(2) {
border-left-width: 2em;
}
Kết quả
Đặc tả kỹ thuật
| Specification |
|---|
| CSS Backgrounds and Borders Module Level 3> # border-width> |
Tương thích trình duyệt
Xem thêm
- Các thuộc tính CSS liên quan đến độ rộng đường viền khác:
border-top-width,border-right-width,border-bottom-width, vàborder-width. - Các thuộc tính CSS liên quan đến đường viền trái khác:
border,border-left,border-left-style, vàborder-left-color.