Flexboxの練習

Flexbox

CSS Flexbox

The "flex-derection: column" stacks the items vertically(from top to bottom): column-reverse(from bottom to top)

1
2
3
4
1
2
3
4

flex-derection: row stacks the items horizontally(from left to right) :row-reverse (from right to left)
flex-wrap: wrap/wrap-reverse;
flex-flow: row wrap;

1
2
3
4
5
6
7
8
9
10
11
12
  .flex-container-row {
    display: flex;
    /*flex-direction: row; */
    background-color: DodgerBlue;
    /*flex-wrap: wrap; */
    flex-flow: row wrap;
  }

flex-flow: row-reverse wrap-reverse;

1
2
3
4
5
6
7
8
9
10
11
12
  .flex-container-rowreverse {
    display: flex;
    /*flex-direction: row-reverse; */
    background-color: lightblue;
    /*flex-wrap: wrap-reverse; */
    flex-flow: row-reverse wrap-reverse;
  }

justify-content: center

1
2
3
4
5
6
7
8
9
10
11
12

justify-content: center;

1
2
3
4
   .flex-container-justify {
    display: flex;
    justify-content: center;
    background-color: DodgerBlue;
    ========
  <div class="flex-container-justify">
  <div>1</div>
  <div>2</div>
  <div>3</div>
  <div>4</div>
</div>  

justify-content: flex-start;

1
2
3
4

justify-content: flex-end;

1
2
3
4

justify-content: space-around;

1
2
3
4
space-around
space-around
object-fit: cover;

justify-content: space-between;

1
2
3
4
space-between
space-between
object-fit: contain;
CSS Styling Images
CSS object-fit
HTML figcaption Tag
HTML img Tag
HTML Global attributes
HTML cite Tag
HTML tag Reference
space-between
object-fit: none;
space-between
object-fit: scale-down;
space-between
object-fit: fill;

align-items: flex-start/ center/ flex-end / stretch/ baseline/;

align-items: flex-start;

1
2
3
4

align-items: center;

1
2
3
4

align-items: flex-end;

1
2
3
4

align-items: stretch;

1
2
3
4

align-items: baseline;/ with headline for character

1

2

3

4

5

6

7

align-content: space-between/ space-around/ stretch/ center/ flex-start/ flex-end/

align-content: space-between;

1
2
3
4
5
6
7
8
9
10
11
12

align-content: space-around;

1
2
3
4
5
6
7
8
9
10
11
12

align-content: stretch;

1
2
3
4
5
6
7
8
9
10
11
12

align-content: center;

1
2
3
4
5
6
7
8
9
10
11
12

align-content: flex-start;

1
2
3
4
5
6
7
8
9
10
11
12

align-content: flex-end;

1
2
3
4
5
6
7
8
9
10
11
12

Perfect Centering

justify-content: center; align-items: center;

1

flex property: flex-grow/flex-shrink/flex-basis
order/align-self/

the order

1
2
3
4
5
6
  <div class="flex-container-justify">
  <div style="order: 4">1</div>
  <div style="order: 2">2</div>
  <div style="order: 6">3</div>
  <div style="order: 1">4</div>
  <div style="order: 3">5</div>
  <div style="order: 5">6</div>
</div>

justify-content: center;

flex-grow: 0(default value) 0~must be a number.0以上の整数。

flex-flow: row-reverse; flex-wrap: wrap-reverse;

1
2
3
4
5
6
.flex-container-rowreverse {
    display: flex;
    /*flex-direction: row-reverse; */
    background-color: lightblue;
    /*flex-wrap: wrap-reverse; */
    flex-flow: row-reverse wrap-reverse;
  }
  =====
  <div class="flex-container-rowreverse">
  <div style="flex-grow: 0">1</div>
  <div style="flex-grow: 1">2</div>
  <div style="flex-grow: 2">3</div>
  <div style="flex-grow: 3">4</div>
  <div style="flex-grow: 0">5</div>
  <div style="flex-grow: 4">6</div>
  </div>
  

flex-shrink: 1(default value);

1
2
3
4
5
6
7
8

1
2
3
4
5
6
7
8
    .flex-shrink {
      display: flex;
      flex-direction: row-reverse; 横並びを逆に
      align-items: stretch;
      justify-content: flex-end;並びを最後に row-reverse があるから 縮小するとflex-startのようになる
      background-color: dodgerblue;
      overflow-x: hidden; 拡大時のx方向のoverflow をなくす。
    }
    .flex-shrink > div {
      color:green;
      background-color: lightgrey;
      width:200px;
      margin: 15px;
      line-height: 75px;
      font-size: 30px;
      text-align: center;
    }
    ==
<div class="flex-shrink">
  <div>1</div> default
  <div style="flex-shrink: 0">2</div> 拡大
  <div style="flex-shrink: 2">3</div> shrink
  <div style="flex-shrink: 1">4</div> default
  <div>5</div> default
  <div>6</div> default
  <div style="flex-shrink: 0">7</div> 拡大
  <div style="flex-shrink: 4">8</div> shrink
  </div>
  

style="flex: 0 0 350px;他はwidth: 200px;
3 not growable(0), not shrinkable(0), width: 350px;

1
2
3
4
5

align-self: flex-start/center/flex-end;

flex-direction: column;

1
2
3
4
The align-self property overrides the align-items property of the container.
全体でoverflow:auto;のclearfix, 
  左はfloat:leftの flex box, flex-direction: column; width: 40%;, 
  右は float: right; overflow-x:auto; width:50%;

<div style="overflow:auto;"
<div class="flex-container-column" style="float: left;">
  <div style=align-self:center;">1</div>
  <div>2</div>
  <div style="align-self: flex-end">3</div>
  <div>4</div>
  <div style="width:auto;">The align-self property overrides the align-items property of the container.</div>
</div>
===========
<pre class="source" style="float: right; width: 50%; overflow-x: auto;">
<div style="overflow:auto;"
<div class="flex-container-column" style="float: left;">

Responsive grid

100% 50% 25% gallery

コメント

このブログの人気の投稿

スタートアップフォルダとAmatsukazeのエンコード設定

EDCB Recname_MacroのRMで文字削除がうまく行かない

冠山トンネル周辺のライブカメラ