Bootstrap 4中的响应式图像

时间:2018-07-08 07:18:50

标签: css html5 bootstrap-4

我在Bootstrap 4.0中有响应图像问题。我使用class="img-fluid",但似乎不起作用。

我在Chrome上使用附加组件检查其他设备(iPhone 4),但该图像无法在设备监视器上缩放。

enter image description here

这是我的代码:

<!doctype html>
    <html lang="en">
    <head>
    <title>Màn hình danh sách điện thoại</title>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
    </head>
    <body>
    <div class="container-fluid">
        <div class="row border border-primary mt-1 ml-1 mr-1 rounded">
            <img src="img/PET.png" style="width: 8rem" class="img-fluid float-left pb-2">
            <div class="col-md-6 text-center text-danger">
                 <h5 class="font-weight-bold">CỬA HÀNG ĐIỆN THOẠI PET</h5>
                 <h5>Địa chỉ: 42 Phạm Ngọc Thạch Phường 6 Quận 3 TP.HCM</h5>
                 <h5>Điện thoại: 0907.888.511</h5>
            </div>
            <div class="col-md-6">      
            </div>
        </div>
    </div>
    <!-- jQuery first, then Popper.js, then Bootstrap JS -->
    <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
  </body>
</html>

我希望这张图片像这样:

enter image description here

3 个答案:

答案 0 :(得分:0)

img中包装div标记,然后在此处而不是在class="img-fluid float-left pb-2"中设置img

并使用col-6进行第二格划分。

请参见小提琴:https://jsfiddle.net/3f5ke0c2/

  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.0/umd/popper.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>
<div class="container-fluid">
    <div class="row border border-primary mt-1 ml-1 mr-1 rounded">
    <div class="img-fluid float-left pb-2">
        <img src="https://material.angular.io/assets/img/examples/shiba1.jpg"
        style="width: 8rem">
    </div>
        <div class="col-6 text-center text-danger">
             <h5 class="font-weight-bold">CỬA HÀNG ĐIỆN THOẠI PET</h5>
             <h5>Địa chỉ: 42 Phạm Ngọc Thạch Phường 6 Quận 3 TP.HCM</h5>
             <h5>Điện thoại: 0907.888.511</h5>
        </div>
        <div class="col-md-6">      
        </div>
    </div>
</div>

答案 1 :(得分:0)

在CSS中尝试

objcon.execute "insert into logs (member,refer) values (12,12345)"
objcon.execute "select top 1 id from logs order by id desc"

答案 2 :(得分:0)

将图像包裹在.row div内的额外div中,如下所示:

<div class="container">
    <div class="row">
        <div class="col">
            <img class="img-fluid" src="my-image.jpg" />
        </div>
    </div>
</div>

注意:.col类不是必需的,但我发现它使事情与使用容器和行时所期望的方式保持一致