Properti fleksibel gaya
Contoh
Biarkan semua item fleksibel memiliki panjang yang sama, terlepas dari isinya:
for (i = 0; i
y[i].style.flex = "1";
}
Definisi dan Penggunaan
Properti flex mengatur atau mengembalikan panjang item, relatif terhadap item fleksibel lainnya di dalam wadah yang sama.
Properti flex adalah singkatan untuk properti flexGrow, flexShrink, dan flexBasis.
Catatan: Jika elemen bukan item fleksibel, properti flex tidak berpengaruh.
Dukungan Peramban
Property | |||||
---|---|---|---|---|---|
flex | Yes | 11.0 10.0 msFlex |
Yes | 9.0 | Yes |
Sintaksis
Kembalikan properti flex:
object.style.flex
Setel properti fleksibel:
object.style.flex = "flex-grow flex-shrink flex-basis|auto|initial|inherit"
Nilai properti
Value | Description |
---|---|
flex-grow | A number specifying how much the item will grow relative to the rest of the flexible items |
flex-shrink | A number specifying how much the item will shrink relative to the rest of the flexible items |
flex-basis | The length of the item. Legal values: "auto", "inherit", or a number followed by "%", "px", "em" or any other length unit |
auto | Same as 1 1 auto. |
initial | Same as 0 1 auto. Read about initial |
none | Same as 0 0 auto. |
inherit | Inherits this property from its parent element. Read about inherit |
Detail Teknis
Nilai Bawaan: | 0 1 otomatis |
---|---|
Nilai Kembali: | Sebuah String, mewakili properti flex dari sebuah elemen |
Versi CSS | CSS3 |
Halaman Terkait
Referensi CSS: properti fleksibel
Referensi GAYA DOM HTML: properti flexBasis
Referensi GAYA DOM HTML: properti flexDirection
Referensi GAYA DOM HTML: properti flexFlow
Referensi GAYA DOM HTML: properti flexGrow
Referensi GAYA DOM HTML: properti flexShrink
Referensi GAYA DOM HTML: properti flexWrap
Objek Gaya