Căn chỉnh theo phong cách Thuộc tính Nội dung
Thí dụ
Định vị các mục của phần tử <div> linh hoạt bằng khoảng cách giữa các dòng:
document.getElementById("main").style.alignContent = "space-between";
Định nghĩa và Cách sử dụng
Thuộc tính alignContent sắp xếp các mục của vùng chứa linh hoạt khi các mục không sử dụng tất cả không gian có sẵn trên trục chéo (theo chiều dọc).
Mẹo: Sử dụng thuộc tính justifyContent để căn chỉnh các mục trên trục chính (theo chiều ngang).
Lưu ý: Phải có nhiều dòng mục thì thuộc tính này mới có hiệu lực.
Hỗ trợ trình duyệt
Các số trong bảng chỉ định phiên bản trình duyệt đầu tiên hỗ trợ đầy đủ thuộc tính.
Các số theo sau bởi Webkit chỉ định phiên bản đầu tiên hoạt động với tiền tố.
Property | |||||
---|---|---|---|---|---|
alignContent | 21.0 | 11.0 | 28.0 | 9.0 7.0 Webkit |
12.1 |
Cú pháp
Trả về thuộc tính alignContent:
object.style.alignContent
Đặt thuộc tính alignContent:
object.style.alignContent = "stretch|center|flex-start|flex-end|space-between|space-around|initial|inherit"
Giá trị tài sản
Value | Description |
---|---|
stretch | Default value. 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 |
space-between | Items are positioned with space between the lines |
space-around | Items are positioned with space before, between, and after the lines |
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: | căng ra |
---|---|
Giá trị trả lại: | Một chuỗi, đại diện cho thuộc tính align-content của một phần tử |
Phiên bản CSS | CSS3 |
Các trang liên quan
Tham chiếu CSS: thuộc tính align-content
HTML DOM STYLE Tham khảo: thuộc tính alignItems
HTML DOM STYLE Tham khảo: thuộc tính alignSelf
HTML DOM STYLE Tham chiếu: thuộc tính justifyContent