Quantcast
Channel: CSSタグが付けられた新着記事 - Qiita
Viewing all articles
Browse latest Browse all 8686

並んだコンポーネントの幅を残りいっぱいにする方法

$
0
0

サンプル

See the Pen GRgJooL by taisukek (@taisukek) on CodePen.

flex-basisとflex-growを利用する

.parent {
 /*子要素にflexレイアウトを適用する*/
  display: flex;
}

.child1 {
 /*要素の幅を100pxに指定*/
  flex: 0 0 100px; 
}

.child2 {
  /*
    要素の幅を残りいっぱいにする
    (<親要素の幅>-<flexレイアウト適用対象のflex-basis値の合計>)
  */
  flex: 1 0 0; 
}

flexとは

flexはflex-grow, flex-shrink, flex-basisの短縮系のため以下2つは同じ

 flex: 1 0 0;
 flex-grow: 1;
 flex-shrink: 0;
 flex-basis: 0;

Viewing all articles
Browse latest Browse all 8686

Latest Images

Trending Articles

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>