From cc784b6bbe3f2caf5a5ac15d740715eb8228514f Mon Sep 17 00:00:00 2001 From: Masahiro FUJIMOTO Date: Thu, 29 Jul 2021 13:59:48 +0900 Subject: conflicting/Web/CSS/CSS_Flexible_Box_Layout 以下を削除 (#1522) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit それぞれ廃止された旧ページであるため --- files/ja/_redirects.txt | 6 +- files/ja/_wikihistory.json | 14 - .../backwards_compatibility_of_flexbox/index.html | 369 --------------------- .../typical_use_cases_of_flexbox/index.html | 192 ----------- 4 files changed, 3 insertions(+), 578 deletions(-) delete mode 100644 files/ja/conflicting/web/css/css_flexible_box_layout/backwards_compatibility_of_flexbox/index.html delete mode 100644 files/ja/conflicting/web/css/css_flexible_box_layout/typical_use_cases_of_flexbox/index.html diff --git a/files/ja/_redirects.txt b/files/ja/_redirects.txt index bbe05c0df0..7cd783785a 100644 --- a/files/ja/_redirects.txt +++ b/files/ja/_redirects.txt @@ -4139,10 +4139,10 @@ /ja/docs/Web/CSS/CSS_Background_and_Borders/Using_CSS_multiple_backgrounds /ja/docs/Web/CSS/CSS_Backgrounds_and_Borders/Using_multiple_backgrounds /ja/docs/Web/CSS/CSS_Backgrounds_and_Borders/Scaling_background_images /ja/docs/Web/CSS/CSS_Backgrounds_and_Borders/Resizing_background_images /ja/docs/Web/CSS/CSS_Colors /en-US/docs/Web/CSS/CSS_Color -/ja/docs/Web/CSS/CSS_Flexible_Box_Layout/Advanced_layouts_with_flexbox /ja/docs/conflicting/Web/CSS/CSS_Flexible_Box_Layout/Backwards_Compatibility_of_Flexbox -/ja/docs/Web/CSS/CSS_Flexible_Box_Layout/Mixins /ja/docs/conflicting/Web/CSS/CSS_Flexible_Box_Layout/Backwards_Compatibility_of_Flexbox +/ja/docs/Web/CSS/CSS_Flexible_Box_Layout/Advanced_layouts_with_flexbox /ja/docs/Web/CSS/CSS_Flexible_Box_Layout/Backwards_Compatibility_of_Flexbox +/ja/docs/Web/CSS/CSS_Flexible_Box_Layout/Mixins /ja/docs/Web/CSS/CSS_Flexible_Box_Layout/Backwards_Compatibility_of_Flexbox /ja/docs/Web/CSS/CSS_Flexible_Box_Layout/Using_CSS_flexible_boxes /ja/docs/Web/CSS/CSS_Flexible_Box_Layout/Basic_Concepts_of_Flexbox -/ja/docs/Web/CSS/CSS_Flexible_Box_Layout/Using_flexbox_to_lay_out_web_applications /ja/docs/conflicting/Web/CSS/CSS_Flexible_Box_Layout/Typical_Use_Cases_of_Flexbox +/ja/docs/Web/CSS/CSS_Flexible_Box_Layout/Using_flexbox_to_lay_out_web_applications /ja/docs/Web/CSS/CSS_Flexible_Box_Layout/Typical_Use_Cases_of_Flexbox /ja/docs/Web/CSS/CSS_Flow_Layout/Formatting_Contexts_Explained /ja/docs/Web/CSS/CSS_Flow_Layout/Intro_to_formatting_contexts /ja/docs/Web/CSS/CSS_Masks /ja/docs/Web/CSS/CSS_Masking /ja/docs/Web/CSS/CSS_Reference /ja/docs/Web/CSS/Reference diff --git a/files/ja/_wikihistory.json b/files/ja/_wikihistory.json index a1ab8f2e0c..c46c0eed4f 100644 --- a/files/ja/_wikihistory.json +++ b/files/ja/_wikihistory.json @@ -48357,20 +48357,6 @@ "DaViD83" ] }, - "conflicting/Web/CSS/CSS_Flexible_Box_Layout/Backwards_Compatibility_of_Flexbox": { - "modified": "2019-03-18T21:27:26.555Z", - "contributors": [ - "mfuji09", - "chrisdavidmills", - "EmptyPond" - ] - }, - "conflicting/Web/CSS/CSS_Flexible_Box_Layout/Typical_Use_Cases_of_Flexbox": { - "modified": "2019-03-23T22:40:47.383Z", - "contributors": [ - "yyss" - ] - }, "conflicting/Web/CSS/Media_Queries/Using_media_queries": { "modified": "2019-03-24T00:02:57.940Z", "contributors": [ diff --git a/files/ja/conflicting/web/css/css_flexible_box_layout/backwards_compatibility_of_flexbox/index.html b/files/ja/conflicting/web/css/css_flexible_box_layout/backwards_compatibility_of_flexbox/index.html deleted file mode 100644 index 7fa1a3b2d7..0000000000 --- a/files/ja/conflicting/web/css/css_flexible_box_layout/backwards_compatibility_of_flexbox/index.html +++ /dev/null @@ -1,369 +0,0 @@ ---- -title: クロスブラウザのフレックスボックスのミックスイン -slug: conflicting/Web/CSS/CSS_Flexible_Box_Layout/Backwards_Compatibility_of_Flexbox -tags: - - CSS - - CSS フレックスボックス - - ミックスイン - - リファレンス -translation_of: Web/CSS/CSS_Flexible_Box_Layout/Mixins -original_slug: Web/CSS/CSS_Flexible_Box_Layout/Mixins ---- -
{{cssref}}
- -

この記事では、 flexbox を現在のブラウザーのネイティブ対応を利用して使いこなしたい人のための一連のミックスインを紹介します。

- -

このセットは次のものを使用します。

- - - -

原文:

- - - -

参考文献:

- - - -
メモ: ミックスインは、現在ブラウザーでは対応されていません。下記の大部分を実行するには、代わりに CSS プリプロセッサーを使用する必要があるでしょう。しかし、 CSS プリプロセッサーは単純に妥当な CSS を生成するので、以下で使用されているテクニックは、推奨される場合は純粋な CSS で書くこともできます。
- -

フレックスボックスのコンテナー

- -

{{cssxref("display")}} プロパティに flex の値を使用すると、要素がブロックレベルのコンテナーボックスを生成します。 inline-flex の値では、要素がインラインレベルのフレックスコンテナーボックスを生成します。

- - - -
@mixin flexbox {
-  display: -webkit-box;
-  display: -moz-box;
-  display: -webkit-flex;
-  display: -ms-flexbox;
-  display: flex;
-}
-
-//Using this mixin
-%flexbox { @include flexbox; }
- -
-
@mixin inline-flex {
-  display: -webkit-inline-box;
-  display: -moz-inline-box;
-  display: -webkit-inline-flex;
-  display: -ms-inline-flexbox;
-  display: inline-flex;
-}
-
-%inline-flex { @include inline-flex; }
-
- -

フレックスボックスの方向

- -

The {{cssxref("flex-direction")}} property specifies how flex items are placed in the flex container, by setting the direction of the flex container's main axis. This determines the direction in which flex items are laid out in.

- - - -
-
@mixin flex-direction($value: row) {
-  @if $value == row-reverse {
-    -webkit-box-direction: reverse;
-    -webkit-box-orient: horizontal;
-    -moz-box-direction: reverse;
-    -moz-box-orient: horizontal;
-  } @else if $value == column {
-    -webkit-box-direction: normal;
-    -webkit-box-orient: vertical;
-    -moz-box-direction: normal;
-    -moz-box-orient: vertical;
-  } @else if $value == column-reverse {
-    -webkit-box-direction: reverse;
-    -webkit-box-orient: vertical;
-    -moz-box-direction: reverse;
-    -moz-box-orient: vertical;
-  } @else {
-    -webkit-box-direction: normal;
-    -webkit-box-orient: horizontal;
-    -moz-box-direction: normal;
-    -moz-box-orient: horizontal;
-  }
-  -webkit-flex-direction: $value;
-  -ms-flex-direction: $value;
-  flex-direction: $value;
-}
-
-// Shorter version:
-@mixin flex-dir($args...) { @include flex-direction($args...); }
-
- -

フレックスボックスの折り返し

- -

The {{cssxref("flex-wrap")}} property controls whether the flex container is single-lined or multi-lined and the direction of the cross-axis, which determines the direction in which the new lines are stacked in.

- - - -
-
@mixin flex-wrap($value: nowrap) {
-  // No Webkit/FF Box fallback.
-  -webkit-flex-wrap: $value;
-  @if $value == nowrap {
-    -ms-flex-wrap: none;
-  } @else {
-    -ms-flex-wrap: $value;
-  }
-  flex-wrap: $value;
-}
-
- -

フレックスボックスのフロー (一括指定)

- -

The {{cssxref("flex-flow")}} property is shorthand for setting the flex-direction and flex-wrap properties, which together define the flex container's main and cross axes.

- - - -
-
@mixin flex-flow($values: (row nowrap)) {
-  // No Webkit/FF Box fallback.
-  -webkit-flex-flow: $values;
-  -ms-flex-flow: $values;
-  flex-flow: $values;
-}
-
- -

フレックスボックスの順序

- -

The {{cssxref("order")}} property controls the order in which flex items appear within their flex container, by assigning them to ordinal groups.

- - - -
-
@mixin order($int: 0) {
-  -webkit-box-ordinal-group: $int + 1;
-  -moz-box-ordinal-group: $int + 1;
-  -webkit-order: $int;
-  -ms-flex-order: $int;
-  order: $int;
-}
-
- -

フレックスボックスの伸長

- -

The {{cssxref("flex-grow")}} property sets the flex grow factor. Negative numbers are invalid.

- - - -
-
@mixin flex-grow($int: 1) {
-  -webkit-box-flex: $int;
-  -moz-box-flex: $int;
-  -webkit-flex-grow: $int;
-  -ms-flex: $int;
-  flex-grow: $int;
-}
-
- -

フレックスボックスの縮小

- -

The {{cssxref("flex-shrink")}} property sets the flex shrink factor. Negative numbers are invalid.

- - - -
-
@mixin flex-shrink($int: 0) {
-  -webkit-flex-shrink: $int;
-  -moz-flex-shrink: $int;
-  -ms-flex: $int;
-  flex-shrink: $int;
-}
-
- -

フレックスボックスの basis

- -

The {{cssxref("flex-basis")}} property sets the flex basis. Negative lengths are invalid.

- - - -
-
@mixin flex-basis($value: auto) {
-  -webkit-flex-basis: $value;
-  flex-basis: $value;
-}
-
- -

フレックスボックスの "flex" (一括指定)

- -

The {{cssxref("flex")}} property specifies the components of a flexible length; flex-grow factor, flex-shrink factor, and the flex-basis. When an element is a flex item, flex is consulted instead of the main size property to determine the main size of the element. If an element is not a flex item, flex has no effect.

- - - -
-
@mixin flex($fg: 1, $fs: 0, $fb: auto) {
-
-  // Set a variable to be used by box-flex properties
-  $fg-boxflex: $fg;
-
-  // Box-Flex only supports a flex-grow value so lets grab the
-  // first item in the list and just return that.
-  @if type-of($fg) == 'list' {
-    $fg-boxflex: nth($fg, 1);
-  }
-
-  -webkit-box: $fg-boxflex;
-  -moz-box: $fg-boxflex;
-  -webkit-flex: $fg $fs $fb;
-  -ms-flexbox: $fg $fs $fb;
-  flex: $fg $fs $fb;
-}
-
- -

フレックスボックスのコンテンツの位置揃え

- -

The {{cssxref("justify-content")}} property aligns flex items along the main axis of the current line of the flex container. This is done after any flexible lengths and any auto margins have been resolved. Typically, it helps to distribute extra free space leftover when either all the flex items on a line are inflexible, or are flexible but have reached their maximum size. It also exerts some control over the alignment of items when they overflow the line.

- -
-

Note: space-* values not supported in older syntaxes.

-
- - - -
-
@mixin justify-content($value: flex-start) {
-  @if $value == flex-start {
-    -webkit-box-pack: start;
-    -moz-box-pack: start;
-    -ms-flex-pack: start;
-  } @else if $value == flex-end {
-    -webkit-box-pack: end;
-    -moz-box-pack: end;
-    -ms-flex-pack: end;
-  } @else if $value == space-between {
-    -webkit-box-pack: justify;
-    -moz-box-pack: justify;
-    -ms-flex-pack: justify;
-  } @else if $value == space-around {
-    -ms-flex-pack: distribute;
-  } @else {
-    -webkit-box-pack: $value;
-    -moz-box-pack: $value;
-    -ms-flex-pack: $value;
-  }
-  -webkit-justify-content: $value;
-  justify-content: $value;
-}
-  // Shorter version:
-  @mixin flex-just($args...) { @include justify-content($args...); }
-
- -

フレックスボックスの項目の配置

- -

Flex items can be aligned in the cross axis of the current line of the flex container, similar to justify-content but in the perpendicular direction. {{cssxref("align-items")}} sets the default alignment for all of the flex container's items, including anonymous flex items. {{cssxref("align-self")}} allows this default alignment to be overridden for individual flex items. (For anonymous flex items, align-self always matches the value of align-items on their associated flex container.)

- - - -
-
@mixin align-items($value: stretch) {
-  @if $value == flex-start {
-    -webkit-box-align: start;
-    -moz-box-align: start;
-    -ms-flex-align: start;
-  } @else if $value == flex-end {
-    -webkit-box-align: end;
-    -moz-box-align: end;
-    -ms-flex-align: end;
-  } @else {
-    -webkit-box-align: $value;
-    -moz-box-align: $value;
-    -ms-flex-align: $value;
-  }
-  -webkit-align-items: $value;
-  align-items: $value;
-}
-
- -

フレックスボックスの自己配置

- -

Values: auto (default) | flex-start | flex-end | center | baseline | stretch

- -

Spec: https://drafts.csswg.org/css-flexbox/#align-items-property

- -
-
@mixin align-self($value: auto) {
-  // No Webkit Box Fallback.
-  -webkit-align-self: $value;
-  @if $value == flex-start {
-    -ms-flex-item-align: start;
-  } @else if $value == flex-end {
-    -ms-flex-item-align: end;
-  } @else {
-    -ms-flex-item-align: $value;
-  }
-  align-self: $value;
-}
-
- -

フレックスボックスのコンテンツの配置

- -

The {{cssxref("align-content")}} property aligns a flex container's lines within the flex container when there is extra space in the cross-axis, similar to how justify-content aligns individual items within the main axis. Note that this property has no effect when the flexbox has only a single line.

- - - -
-
@mixin align-content($value: stretch) {
-  // No Webkit Box Fallback.
-  -webkit-align-content: $value;
-  @if $value == flex-start {
-    -ms-flex-line-pack: start;
-  } @else if $value == flex-end {
-    -ms-flex-line-pack: end;
-  } @else {
-    -ms-flex-line-pack: $value;
-  }
-  align-content: $value;
-}
-
diff --git a/files/ja/conflicting/web/css/css_flexible_box_layout/typical_use_cases_of_flexbox/index.html b/files/ja/conflicting/web/css/css_flexible_box_layout/typical_use_cases_of_flexbox/index.html deleted file mode 100644 index 8f7ad0278f..0000000000 --- a/files/ja/conflicting/web/css/css_flexible_box_layout/typical_use_cases_of_flexbox/index.html +++ /dev/null @@ -1,192 +0,0 @@ ---- -title: Web アプリケーションのレイアウトに flexbox を使用する -slug: conflicting/Web/CSS/CSS_Flexible_Box_Layout/Typical_Use_Cases_of_Flexbox -tags: - - Advanced - - CSS - - CSS Flexible Boxes - - Example - - Guide - - Web -translation_of: Web/CSS/CSS_Flexible_Box_Layout/Typical_Use_Cases_of_Flexbox -translation_of_original: Web/CSS/CSS_Flexible_Box_Layout/Using_flexbox_to_lay_out_web_applications -original_slug: Web/CSS/CSS_Flexible_Box_Layout/Using_flexbox_to_lay_out_web_applications ---- -
{{CSSRef}}
- -

flexbox は、デスクトップからモバイルまで対応する Web アプリケーションのレイアウト設計で助けになります。浮動状態の {{HTMLElement("div")}} 要素、絶対位置指定、JavaScript による細工をなくして、数行の CSS だけで水平方向または垂直方向のフローレイアウトを構築します。基本的な用途例を挙げます:

- - - -

この記事では、接頭辞がない現行の標準仕様をサポートするブラウザで flexbox を使用する方法を扱います。古いブラウザ向けのベンダー接頭辞については、CSS flexible box の使用に関する、より一般的なガイドをご覧ください。

- -

基本

- -

任意の {{HTMLElement("div")}} 要素で {{cssxref("display")}} プロパティに flex を、また {{cssxref("flex-flow")}} に row (要素を水平に並べたい場合) または column (要素を垂直に並べたい場合) を設定すると、内部の要素を flexbox のフローにすることができます。水平方向の flexbox を使用していて内容物を垂直方向に折り返したい場合は、値 wrap も指定します。

- -

そして、flex フローの一部として組み込みたい要素に {{cssxref("flex")}} プロパティを指定します。通常、以下の 3 種類の値のいずれかを使用するでしょう:

- - - -

もちろん他にも使用できる値はありますが、それらは基本的な使用方法を超えるものでしょう。これらの値がどのように適用されるかを、いくつかの例で見ていきましょう。

- -

ページ内の中央に要素を配置する

- -

このような使い方でもっとも簡単な方法は、2 つの flexible box を入れ子にすることです。それぞれの flexbox 内に要素が 3 つあります。そのうち 2 つが詰め物になって、残る要素が中央に置かれます。

- -

CSS コンテンツ

- -
.vertical-box {
-  display: flex;
-  height: 400px;
-  width: 400px;
-  flex-flow: column;
-}
-.horizontal-box {
-  display: flex;
-  flex-flow: row;
-}
-.spacer {
-  flex: auto;
-  background-color: black;
-}
-.centered-element {
-  flex: none;
-  background-color: white;
-}
-
- -

HTML コンテンツ

- -
<div class="vertical-box">
-  <div class="spacer"></div>
-  <div class="centered-element horizontal-box">
-    <div class="spacer"></div>
-    <div class="centered-element">Centered content</div>
-     <div class="spacer"></div>
-  </div>
-  <div class="spacer"></div>
-</div>
-
- -

結果

- -

{{EmbedLiveSample('Centering_an_element_inside_a_page', 500, 500)}}

- -

複数のコンテナを垂直方向に並べる

- -

ヘッダーセクション、コンテンツセクション、フッターセクションがあるレイアウトのページを思い浮かべてください。ヘッダーとフッターのサイズは固定しますが、コンテンツセクションは使用できる領域に応じてリサイズします。これはコンテンツセクションの {{cssxref("flex")}} プロパティを auto に、またヘッダーおよびフッターの {{cssxref("flex")}} プロパティを none にすることで実現できます。

- -

CSS コンテンツ

- -
.vertical-box {
-  display: flex;
-  height: 400px;
-  width: 400px;
-  flex-flow: column;
-}
-.fixed-size {
-  flex: none;
-  height: 30px;
-  background-color: black;
-  text-align: center;
-}
-.flexible-size {
-  flex: auto;
-  background-color: white;
-}
-
- -

HTML コンテンツ

- -
<div id="document" class="vertical-box">
-  <div class="fixed-size"><button id="increase-size">Increase container size</button></div>
-  <div id="flexible-content" class="flexible-size"></div>
-  <div class="fixed-size"><button id="decrease-size">Decrease container size</button></div>
-</div>
-
- -

Javascript コンテンツ

- -
var height = 400;
-document.getElementById('increase-size').onclick=function() {
-  height += 10;
-  if (height > 500) height = 500;
-  document.getElementById('document').style.height = (height + "px");
-}
-
-document.getElementById('decrease-size').onclick=function() {
-  height -= 10;
-  if (height < 300) height = 300;
-  document.getElementById('document').style.height = (height + "px");
-}
- -

結果

- -

{{EmbedLiveSample('Flowing_a_set_of_containers_vertically', 500, 500)}}

- -

この例はヘッダーのボタンをクリックするとサイズが拡大、フッターのボタンをクリックするとサイズが縮小するようになっています。ヘッダーやフッターのサイズを一定にしたままで、どのようにしてコンテンツセクションを自動的に適切なサイズに変えているかを確認してください。

- -

折り返される水平方向のコンテナを作成する

- -

スクリーンサイズに余裕があれば水平方向に情報一式を並べますが、そうでない場合は水平方向のレイアウトを崩したい場合があるかもしれません。これは、flexbox を使用すればとても簡単です。{{cssxref("flex-flow")}} プロパティに値 wrap を追加すると実現できます。

- -

CSS コンテンツ

- -
.horizontal-container {
-  display: flex;
-  width: 300px;
-  flex-flow: row wrap;
-}
-.fixed-size {
-  flex: none;
-  width: 100px;
-  background-color: black;
-  color: white;
-  text-align: center;
-}
-
- -

HTML コンテンツ

- -
<div id="container" class="horizontal-container">
-  <div class="fixed-size">Element 1</div>
-  <div class="fixed-size">Element 2</div>
-  <div class="fixed-size">Element 3</div>
-</div><button id="increase-size">Increase container size</button><button id="decrease-size">Decrease container size</button>
-
- -

Javascript コンテンツ

- -
var width = 300;
-
-document.getElementById('increase-size').onclick=function() {
-  width += 100;
-  if (width > 300) width = 300;
-  document.getElementById('container').style.width = (width + "px");
-}
-
-document.getElementById('decrease-size').onclick=function() {
-  width -= 100;
-  if (width < 100) width = 100;
-  document.getElementById('container').style.width = (width + "px");
-}
-
- -

結果

- -

{{EmbedLiveSample('Creating_a_collapsing_horizontal_container', 500, 200)}}

- -

関連情報

- - -- cgit v1.2.3-54-g00ecf