グリッドオプション(レスポンシブ)
HTMLの記述
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="utf-8">
<title>グリッドシステム</title>
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css" integrity="sha384-PsH8R72JQ3SOdhVi3uxftmaW6Vc51MKb0q5P2rRUpPvrszuE4W1povHYgTpBfshb" crossorigin="anonymous">
<style>
.orange {
background-color: orange;
border: black 1px solid;
}
</style>
</head>
<body>
<div class="container">
<!-- Grid option -->
<div class="row">
<div class="col orange">A</div>
<div class="col orange">B</div>
<div class="col orange">C</div>
</div>
<div class="row">
<div class="col-sm orange">A</div>
<div class="col-sm orange">B</div>
<div class="col-sm orange">C</div>
</div>
<div class="row">
<div class="col-lg orange">A</div>
<div class="col-lg orange">B</div>
<div class="col-lg orange">C</div>
</div>
<div class="row">
<div class="col-lg-1 orange">1</div>
<div class="col-lg-1 orange">1</div>
<div class="col-lg-1 orange">1</div>
<div class="col-lg-1 orange">1</div>
<div class="col-lg-1 orange">1</div>
<div class="col-lg-1 orange">1</div>
<div class="col-lg-1 orange">1</div>
<div class="col-lg-1 orange">1</div>
<div class="col-lg-1 orange">1</div>
<div class="col-lg-1 orange">1</div>
<div class="col-lg-1 orange">1</div>
<div class="col-lg-1 orange">1</div>
</div>
<div class="row">
<div class="col-lg-1 col-md-2 orange">1</div>
<div class="col-lg-1 col-md-2 orange">1</div>
<div class="col-lg-1 col-md-2 orange">1</div>
<div class="col-lg-1 col-md-2 orange">1</div>
<div class="col-lg-1 col-md-2 orange">1</div>
<div class="col-lg-1 col-md-2 orange">1</div>
<div class="col-lg-1 col-md-2 orange">1</div>
<div class="col-lg-1 col-md-2 orange">1</div>
<div class="col-lg-1 col-md-2 orange">1</div>
<div class="col-lg-1 col-md-2 orange">1</div>
<div class="col-lg-1 col-md-2 orange">1</div>
<div class="col-lg-1 col-md-2 orange">1</div>
</div>
<!-- 入れ子 -->
<div class="row">
<div class="col-sm-9 orange">
Level 1: 9
<div class="row">
<div class="col-sm-8 orange">
Level 2: 8
</div>
<div class="col-sm-4 orange">
Level 2: 4
</div>
</div>
</div>
<div class="col-sm-3 orange">
Level 1: 3
</div>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous">
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.3/umd/popper.min.js" integrity="sha384-vFJXuSJphROIrBnz7yo7oB41mKfc8JzQZiCq4NCceLEaO4IHwicKwpJf9c9IpFgh" crossorigin="anonymous">
</script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/js/bootstrap.min.js" integrity="sha384-alpBpkh1PFOepccYVYDB4do5UnbKysX5WZXm3XxPqe5iKTfUKjNkCk9SaVuEZflJ" crossorigin="anonymous">
</script>
</body>
</html>
※ポイント
- class = “container”(固定枠)か”container-fluid”(流動枠)の中に書く
- class = “row”の中に書く
- class = “col-{prefix}-{columns}”の形で書くこと
- class = {columns}は合計が12になるようにする
補足:prefixはsm,lg,md,などの決められた画面幅を下回った時表示を変える指定でxs(スマホなど〜767px)からlg(PC大画面1120px~)となっている