在Bootstrap中以相反的顺序包装弹性物品

要以相反顺序包装flex项目,您需要在Bootstrap中使用flex-wrap-reverse类。

要包装反向flex项目,请使用flex-wrap-reverse类-

<div class="d-flex flex-wrap-reverse bg-secondary text-white">

现在相应地添加弹性项目-

<div class="d-flex flex-wrap-reverse bg-secondary text-white">
  <div class="p-2 border">Rank 1</div>
  <div class="p-2 border">Rank 2</div>
  <div class="p-2 border">Rank 3</div>
  <div class="p-2 border">Rank 4</div>
</div>

让我们看一个例子来实现flex-wrap-reverse类-

示例

<!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://cdn.staticfile.org/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">
      <h2>Wrap</h2>
      <p>Flex Wrap</p>
      <div class="d-flex flex-wrap bg-secondary text-white">
        <div class="p-2 border">Rank 1</div>
        <div class="p-2 border">Rank 2</div>
        <div class="p-2 border">Rank 3</div>
        <div class="p-2 border">Rank 4</div>
        <div class="p-2 border">Rank 5</div>
        <div class="p-2 border">Rank 6</div>
        <div class="p-2 border">Rank 7</div>
        <div class="p-2 border">Rank 8</div>
        <div class="p-2 border">Rank 9</div>
        <div class="p-2 border">Rank 10</div>
        <div class="p-2 border">Rank 11</div>
        <div class="p-2 border">Rank 12</div>
        <div class="p-2 border">Rank 13</div>
        <div class="p-2 border">Rank 14</div>
        <div class="p-2 border">Rank 15</div>
        <div class="p-2 border">Rank 16</div>
        <div class="p-2 border">Rank 17</div>
        <div class="p-2 border">Rank 18</div>
        <div class="p-2 border">Rank 19</div>
        <div class="p-2 border">Rank 20</div>
      </div><br>
      <p>Flex Wrap - Reverse</p>
      <div class="d-flex flex-wrap-reverse bg-secondary text-white">
        <div class="p-2 border">Rank 1</div>
        <div class="p-2 border">Rank 2</div>
        <div class="p-2 border">Rank 3</div>
        <div class="p-2 border">Rank 4</div>
        <div class="p-2 border">Rank 5</div>
        <div class="p-2 border">Rank 6</div>
        <div class="p-2 border">Rank 7</div>
        <div class="p-2 border">Rank 8</div>
        <div class="p-2 border">Rank 9</div>
        <div class="p-2 border">Rank 10</div>
        <div class="p-2 border">Rank 11</div>
        <div class="p-2 border">Rank 12</div>
        <div class="p-2 border">Rank 13</div>
        <div class="p-2 border">Rank 14</div>
        <div class="p-2 border">Rank 15</div>
        <div class="p-2 border">Rank 16</div>
        <div class="p-2 border">Rank 17</div>
        <div class="p-2 border">Rank 18</div>
        <div class="p-2 border">Rank 19</div>
        <div class="p-2 border">Rank 20</div>
      </div>
   </div>
 </body>
</html>