Bootstrap:强制单元格高度在剩余屏幕上伸展

时间:2018-06-02 23:03:04

标签: css html5 web layout bootstrap-4

我想使用bootstrap 4.0来创建布局2行x 3列布局。我还有一个导航栏,我从这个例子中排除了,因为它没有必要。

我希望2 x 3布局能够在整个剩余屏幕尺寸上均匀地拉伸行的高度,而无需调用垂直滚动条。目前我正在使用"身高:600px"在控制细胞的高度。我认为这个解决方案不适合其他设备。有没有办法以相对的方式实现这一目标。

<!doctype html>
<html lang="en">
  <head>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

    <!-- Bootstrap CSS -->
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" integrity="sha384-WskhaSGFgHYWDcbwN70/dfYBj47jz9qbsMId/iRN3ewGhXQFZCSftd1LZCfmhktB" crossorigin="anonymous">

    <title>Hello, world!</title>

    <style>
      .my-row {
        height: 600px
      }
    </style>
  </head>
  <body>
    <!-- Optional JavaScript -->
    <!-- jQuery first, then Popper.js, then Bootstrap JS -->
    <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js" integrity="sha384-smHYKdLADwkXOn1EmN1qk/HfnUcbVRZyYmZ4qpPea6sjB/pTJ0euyQp0Mk8ck+5T" crossorigin="anonymous"></script>

    <div class="wrapper container-fluid ">
            <div class="row justify-content-center align-items-stretch my-row">
                <div class="col-md-4">Widget 1</div>
                <div class="col-md-4">Widget 2</div>
                <div class="col-md-4">Widget 3</div>

                <!-- Force next columns to break to new line -->
                <div class="w-100"></div>

                <div class="col-md-4">Widget 4</div>
                <div class="col-md-4">Widget 5</div>
                <div class="col-md-4">Widget 6</div>
            </div>
        </div>  
  </body>
</html>

0 个答案:

没有答案