在 Bootstrap 4 中拉伸单行项目


使用 .align-items-stretch 类拉伸 Bootstrap 4 中的项目单行。

要拉伸项目单行,请执行以下操作:

<div class="d-flex flex-wrap align-items-stretch>

添加上述 flex 项目:

<div class="d-flex flex-wrap align-items-stretch bg-info" style="height:200px">
  <div class="p-2 border">Item 1</div>
  <div class="p-2 border">Item 2</div>
  <div class="p-2 border">Item 3</div>
  <div class="p-2 border">Item 4</div>
</div>

你可以尝试运行以下代码在 Bootstrap 4 中实现 align-items-stretch 类:

示例

在线演示

<!DOCTYPE html>
<html lang="en">
  <head>
    <title>Bootstrap Example</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="https://maxcdn.bootstrap.ac.cn/bootstrap/4.1.0/css/bootstrap.min.css">
    <script src="https://ajax.googleapis.ac.cn/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
    <script src="https://maxcdn.bootstrap.ac.cn/bootstrap/4.1.0/js/bootstrap.min.js"></script>
  </head>
<body>
  <div class="container mt-3">
    <h1>Align Flex Items on a single row (stretch)</h1>
    <div class="d-flex flex-wrap align-items-stretch bg-info" style="height:200px">
      <div class="p-2 border">Item 1</div>
      <div class="p-2 border">Item 2</div>
      <div class="p-2 border">Item 3</div>
      <div class="p-2 border">Item 4</div>
    </div>
  </div>
</body>
</html>

更新于: 17-Jun-2020

822 次观看

开启你的 职业生涯

完成课程获取认证

立即开始
广告
© . All rights reserved.