【问题标题】:Place image in Bootstrap card on bottom right将图像放在右下角的 Bootstrap 卡中
【发布时间】:2020-06-25 16:52:31
【问题描述】:

希望你们一切都好。

在卡片右下角放置一张小图片时,我需要一些帮助。现在,它在左边,我试过“bottom:0;top:0;”在 card-img-bottom 类上,但它不起作用。提前致谢。

<!doctype html>
<html lang="en">
  <head>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

    <!-- Bootstrap CSS -->
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css" integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk" crossorigin="anonymous">

    <title>Hello, world!</title>
    <style>
        .card-img-bottom {  
            bottom: 0; right: 0;
        }
    </style>
  </head>
  <body>
    <div class="card" style="width: 18rem;">
        <div class="card-body">
          <p class="card-text">Car</p>
        </div>
        <img style="height:50px;width:100px;" class="card-img-bottom" src="https://static.vecteezy.com/system/resources/thumbnails/000/623/239/small/auto_car-16.jpg" alt="Card image cap">
      </div>
    <!-- Optional JavaScript -->
    <!-- jQuery first, then Popper.js, then Bootstrap JS -->
    <script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
    <script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js" integrity="sha384-OgVRvuATP1z7JjHLkuOU7Xw704+h835Lr+6QL9UvYjZE3Ipu6Tp75j7Bh/kR0JKI" crossorigin="anonymous"></script>
  </body>
</html>

【问题讨论】:

    标签: html css


    【解决方案1】:

    试试position: absolute。我希望它会起作用。

    <style>
        .card-img-bottom {
            position: absolute;
            bottom: 0; 
            right: 0;
        }
    </style>
    

    【讨论】:

      【解决方案2】:

      用这个替换图像样式

      <img style="height:50px;width:100px; float: right; position: absolute">
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2016-03-22
        • 2020-07-07
        • 1970-01-01
        • 2019-04-10
        • 2011-11-09
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多