如何在Bootstrap 4的小屏幕中使卡体水平

时间:2019-05-01 15:01:12

标签: html html5 twitter-bootstrap css3 bootstrap-4

我想使用引导程序4在小型(移动)屏幕中使卡水平放置。

如下图所示,台式机/大屏幕中的卡垂直,移动/小屏幕中的卡水平。

enter image description here

 <div class="card-deck py-4">
      <div class="card">
          <img src="../images/providers/tw-s01.svg" style="width:100%" class="card-imm-3"/>
              <div class="card-body">
                  <div class="card-title card-headtext">step 1</div>
                  <div class="card-text cardtext">Register for a free 
                  account</div>
              </div>
            </div>
 </div>

2 个答案:

答案 0 :(得分:0)

您可以使用引导类,例如.col-sm(用于小屏幕)、. col-lg(用于大屏幕)等,结合使用这些类来调整每个设备的div 在这里阅读更多 https://www.w3schools.com/bootstrap/bootstrap_grid_examples.asp

答案 1 :(得分:-1)

这是您的答案。.您必须包括card-group标记才能实现此目的,并且在使用bootstrap 4 plz之前,请先从bootstrap docs [nktutorial][2]阅读其文档。

<div class="card-group">
      <div class="card">
        <img class="card-img-top" src=".../100px180/" alt="Card image cap">
        <div class="card-body">
          <h5 class="card-title">Card title</h5>
          <p class="card-text">This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
          <p class="card-text"><small class="text-muted">Last updated 3 mins ago</small></p>
        </div>
      </div>
      <div class="card">
        <img class="card-img-top" src=".../100px180/" alt="Card image cap">
        <div class="card-body">
          <h5 class="card-title">Card title</h5>
          <p class="card-text">This card has supporting text below as a natural lead-in to additional content.</p>
          <p class="card-text"><small class="text-muted">Last updated 3 mins ago</small></p>
        </div>
      </div>
      <div class="card">
     <a href="https://nktutorial.com"> <img class="card-img-top" src=".../100px180/" alt="Card image cap"></a>
        <div class="card-body">
          <h5 class="card-title">Card title</h5>
          <p class="card-text">This is a wider card with supporting text below as a natural lead-in to additional content. This card has even longer content than the first to show that equal height action.</p>
          <p class="card-text"><small class="text-muted">Last updated 3 mins ago</small></p>
        </div>
      </div>
    </div>