Proprietà flessibile di stile
Esempio
Lascia che tutti gli elementi flessibili abbiano la stessa lunghezza, indipendentemente dal suo contenuto:
for (i = 0; i
y[i].style.flex = "1";
}
Definizione e utilizzo
La proprietà flex imposta o restituisce la lunghezza dell'elemento, rispetto al resto degli elementi flessibili all'interno dello stesso contenitore.
La proprietà flex è una scorciatoia per le proprietà flexGrow, flexShrink e flexBasis.
Nota: se l'elemento non è un elemento flessibile, la proprietà flex non ha effetto.
Supporto browser
Property | |||||
---|---|---|---|---|---|
flex | Yes | 11.0 10.0 msFlex |
Yes | 9.0 | Yes |
Sintassi
Restituisce la proprietà flex:
object.style.flex
Imposta la proprietà flessibile:
object.style.flex = "flex-grow flex-shrink flex-basis|auto|initial|inherit"
Valori di proprietà
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 |
Dettagli tecnici
Valore di default: | 0 1 automatico |
---|---|
Valore di ritorno: | Una stringa, che rappresenta la proprietà flex di un elemento |
Versione CSS | CSS3 |
Pagine correlate
Riferimento CSS: proprietà flex
HTML DOM STYLE Riferimento: proprietà flexBasis
HTML DOM STYLE Riferimento: proprietà flexDirection
HTML DOM STYLE Riferimento: proprietà flexFlow
HTML DOM STYLE Riferimento: proprietà flexGrow
HTML DOM STYLE Riferimento: proprietà flexShrink
HTML DOM STYLE Riferimento: proprietà flexWrap
❮ Oggetto stile