Thuộc tính kiểu căn chỉnhItems
Ví dụ
Định vị các căn chỉnh cho tất cả các mục của phần tử <div> linh hoạt ở đầu vùng chứa:
document.getElementById("main").style.alignItems = "flex-start";
Hãy tự mình thử »Sự miêu tả
Thuộc tính AlignItems chỉ định cách căn chỉnh mặc định cho các mục bên trong vùng chứa linh hoạt.
Mẹo: Sử dụng thuộc tính Align-self của từng mục để ghi đè thuộc tính Align-items.
Cú pháp
Trả về thuộc tính AlignItems:
object .style.alignItems
Đặt thuộc tính AlignItems:
object .style.alignItems = "stretch|center|flex-start|flex-end|baseline|initial|inherit"
Giá trị tài sản
Value | Description |
---|---|
stretch | Default. Items are stretched to fit the container |
center | Items are positioned at the center of the container |
flex-start | Items are positioned at the beginning of the container |
flex-end | Items are positioned at the end of the container |
baseline | Items are positioned at the baseline of the container |
initial | Sets this property to its default value. Read about initial |
inherit | Inherits this property from its parent element. Read about inherit |
Chi tiết kỹ thuật
Giá trị mặc định: | kéo dài |
---|---|
Giá trị trả về: | Một Chuỗi, biểu thị thuộc tính Align-items của một phần tử |
Phiên bản CSS | CSS3 |
Hỗ trợ trình duyệt
alignItems
là một tính năng của CSS3 (1999).
Nó được hỗ trợ đầy đủ trong tất cả các trình duyệt:
Chrome | Edge | Firefox | Safari | Opera | IE |
Yes | Yes | Yes | Yes | Yes | 11 |
Trang liên quan
Tham chiếu CSS: thuộc tính Align-items
HTML DOM STYLE Tham chiếu: thuộc tính AlignContent
HTML DOM STYLE Tham chiếu: thuộc tính AlignSelf