スタイルフレックスプロパティ
例
内容に関係なく、すべてのフレキシブルアイテムを同じ長さにします。
for (i = 0; i
y[i].style.flex = "1";
}
定義と使用法
flexプロパティは、同じコンテナ内の残りのフレキシブルアイテムを基準にして、アイテムの長さを設定または返します。
flexプロパティは、flexGrow、flexShrink、およびflexBasisプロパティの省略形です。
注:要素がフレキシブルアイテムでない場合、flexプロパティは効果がありません。
ブラウザのサポート
Property | |||||
---|---|---|---|---|---|
flex | Yes | 11.0 10.0 msFlex |
Yes | 9.0 | Yes |
構文
flexプロパティを返します。
object.style.flex
flexプロパティを設定します。
object.style.flex = "flex-grow flex-shrink flex-basis|auto|initial|inherit"
プロパティ値
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 |
技術的な詳細
デフォルト値: | 01自動 |
---|---|
戻り値: | 要素のflexプロパティを表す文字列 |
CSSバージョン | CSS3 |
関連ページ
CSSリファレンス:flexプロパティ
HTML DOM STYLEリファレンス:flexBasisプロパティ
HTML DOM STYLEリファレンス:flexDirectionプロパティ
HTML DOM STYLEリファレンス:flexFlowプロパティ
HTML DOM STYLEリファレンス:flexGrowプロパティ
HTML DOM STYLEリファレンス:flexShrinkプロパティ
HTML DOM STYLEリファレンス:flexWrapプロパティ
❮スタイルオブジェクト