【问题标题】:How to position button at the bottom of the boostrap 4 card?如何将按钮定位在 bootstrap 4 卡的底部?
【发布时间】:2021-08-02 04:26:27
【问题描述】:

是否可以在 boostrap 卡的垂直端放置按钮?卡片会自动填充空白以保持所有相同的高度,但是无论特定卡片的高度如何,如何在卡片的末尾放置一个按钮?

【问题讨论】:

    标签: alignment vertical-alignment card


    【解决方案1】:

    您可以简单地将按钮添加到卡片页脚(Bootstrap 中的卡片页脚类)并设置页脚背景颜色和边框的样式,使其在视觉上看起来像是卡片主体的一部分。 看一下这个: Codepen

    .card {
      border-radius: 10px !important;
      box-shadow: 0 0 15px 0 rgba(0, 0, 0, 0.2);
    }
    
    .card-header {
      border-radius: 10px 10px 0 0 !important;
      background-color: #FCCF23 !important;
    }
    
    .card-footer {
      border-radius: 0 0 10px 10px !important;
      background-color: white !important;
      border: 0 !important;
    }
    
    .card-footer p {
      display: none;
    }
    
    .card-footer button {
      color: #FCCF23;
      background-color: #52134B;
      font-weight: 500;
      border: 0;
      border-radius: 5px;
      padding: 8px 15px;
      transition: all .5s;
    }
    .card-footer button:hover {
      color: #52134B;
      background-color: #FCCF23;
      transition: all .5;  
    }
    
    
    
    /*delete the following codes to make footer totally invisible*/
    .card-footer {
      border-top: dashed 2px rgba(0,0,0,.05) !important;
    }
    .card-footer p {
      display: block;
      color: rgba(0,0,0,.1);
    }
    <link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.5.0/css/bootstrap.min.css" rel="stylesheet"/>
    
    
        <div class="card b-0 w-50 m-5 text-center">
          <h4 class="card-header border-0 p-4">I am a Bootstrap Card Header</h4>
          <p class="card-body p-4">I am a Bootstrap card Body. You can add as many texts as you want here, yet, the button will be remained at the bottom of the card!</p>
          <div class="card-footer pt-0 pb-4 px-4">
            <p class="my-2">I am an 'invisible' Bootstrap Card Footer</p>
            <button type="submit">hover me!</button>
          </div>
        </div>

    【讨论】:

      猜你喜欢
      • 2018-07-02
      • 2018-07-23
      • 2021-06-10
      • 2023-03-12
      • 1970-01-01
      • 1970-01-01
      • 2020-08-22
      • 1970-01-01
      相关资源
      最近更新 更多