如何将两张牌居中(Bootstrap)?

How to center the two cards (Bootstrap)?

[网站][1] [1]: https://i.stack.imgur.com/CmQRP.png

你好,我想把我的两张卡片居中,但我不知道该怎么做。

  <div>
    <div class="card" style="width: 18rem;">
      <img class="card-img-top" src="img/v.jpg" alt="Card image cap" style="width: 286px; height: 180px;">
      <div class="card-body">
        <h5 class="card-title">Card title</h5>
        <p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
        <a href="#" class="btn btn-primary">Go somewhere</a>
      </div>
    </div>
  </div>
</div>
<div>
  <div >
    <div class="card" style="width: 18rem;">
      <img class="card-img-top" src="img/v.jpg" alt="Card image cap" style="width: 286px; height: 180px;">
      <div class="card-body">
        <h5 class="card-title">Card title</h5>
        <p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
        <a href="#" class="btn btn-primary">Go somewhere</a>
      </div>
    </div>
  </div>
</div>```


  [1]: https://i.stack.imgur.com/CmQRP.png

将你所有的卡片包裹在一个容器中并添加以下代码:

.container {
  display: flex;
  width: 80vw; //Change the value if your want
  margin: auto;
/*   flex-direction: column; */ //Uncomment if you want the card to be in a line
}

在每张卡片中:

.card {
  flex: 1;
}