Właściwość elastycznego stylu
Przykład
Niech wszystkie elastyczne elementy będą tej samej długości, niezależnie od ich zawartości:
for (i = 0; i
y[i].style.flex = "1";
}
Definicja i użycie
Właściwość flex ustawia lub zwraca długość elementu w stosunku do pozostałych elementów elastycznych w tym samym kontenerze.
Właściwość flex jest skrótem dla właściwości flexGrow, flexShrink i flexBasis.
Uwaga: Jeśli element nie jest elementem elastycznym, właściwość flex nie ma wpływu.
Obsługa przeglądarki
Property | |||||
---|---|---|---|---|---|
flex | Yes | 11.0 10.0 msFlex |
Yes | 9.0 | Yes |
Składnia
Zwróć właściwość flex:
object.style.flex
Ustaw właściwość flex:
object.style.flex = "flex-grow flex-shrink flex-basis|auto|initial|inherit"
Wartości nieruchomości
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 |
Szczegóły techniczne
Domyślna wartość: | 0 1 auto |
---|---|
Wartość zwrotu: | String, reprezentujący właściwość flex elementu |
Wersja CSS | CSS3 |
Powiązane strony
Odniesienie CSS: właściwość flex
Odniesienie HTML DOM STYLE: właściwość flexBasis
HTML DOM STYLE Reference: właściwość flexDirection
Odniesienie HTML DOM STYLE: właściwość flexFlow
Odniesienie HTML DOM STYLE: właściwość flexGrow
Odniesienie HTML DOM STYLE: właściwość flexShrink
Odniesienie HTML DOM STYLE: właściwość flexWrap
❮ Obiekt stylu