在 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.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/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.