CSSflex -directionプロパティ
例
<div>要素内の柔軟なアイテムの方向を逆の順序で設定します。
div
{
display: flex;
flex-direction: row-reverse;
}
ヒント:以下の「自分で試してみてください」の例をさらに示します。
定義と使用法
flex-direction
プロパティは、フレキシブルアイテムの方向を指定します。
注:要素がフレキシブルアイテムでない場合、flex-direction
プロパティは効果がありません。
デフォルト値: | 行 |
---|---|
遺伝性の: | いいえ |
アニメート可能: | 番号。アニメート可能について読む |
バージョン: | CSS3 |
JavaScript構文: | object .style.flexDirection = "column-reverse" |
ブラウザのサポート
表の数字は、プロパティを完全にサポートする最初のブラウザバージョンを示しています。
数字の後に-webkit-または-moz-が続く場合は、プレフィックスを使用して機能した最初のバージョンを指定します。
Property | |||||
---|---|---|---|---|---|
flex-direction | 29.0 21.0 -webkit- |
11.0 | 28.0 18.0 -moz- |
9.0 6.1 -webkit- |
17.0 |
CSS構文
flex-direction: row|row-reverse|column|column-reverse|initial|inherit;
プロパティ値
Value | Description | Play it |
---|---|---|
row | Default value. The flexible items are displayed horizontally, as a row | |
row-reverse | Same as row, but in reverse order | |
column | The flexible items are displayed vertically, as a column | |
column-reverse | Same as column, but in reverse order | |
initial | Sets this property to its default value. Read about initial | |
inherit | Inherits this property from its parent element. Read about inherit |
その他の例
例
メディアクエリflex-direction
と一緒に使用して、さまざまな画面サイズ/デバイス用にさまざまなレイアウトを作成します。
.flex-container {
display: flex;
flex-direction: row;
}
/*
Responsive layout - makes a one column layout instead of a two-column layout
*/
@media (max-width: 800px) {
.flex-container {
flex-direction: column;
}
}
関連ページ
CSSチュートリアル:CSSフレキシブルボックス
CSSリファレンス:flex-flowプロパティ
CSSリファレンス:flex-wrapプロパティ
CSSリファレンス:flexプロパティ
CSSリファレンス:flex-growプロパティ
CSSリファレンス:flex-shrinkプロパティ
CSSリファレンス:flex-basisプロパティ
HTML DOMリファレンス:flexDirectionプロパティ