在列上设置相同的高度

问题描述 投票:0回答:1

我正在用Bootstrap 3做两列的行。我正在为一个网上商店编程,那里有大约100,000种产品,因此还没有转换为BS4。因此,我被迫使用BS3。左列将包含背景色和一些文本,而右列将是图像。

这是现在的样子:

  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
<div class="wrapper">
    <div class="row">
        <div class="col-sm-3" style="background-color:pink;">
            <h3>Headline</h3>
            <p>Some text here</p>
            <button type="button" class="btn btn-info">Button</button>
        </div>
        <div class="col-sm-9">
            <img src="http://placehold.it/900x200">
        </div>
    </div>
</div>

这是我的最终结果应该是:enter image description here

html css twitter-bootstrap-3
1个回答
0
投票

正如在评论中所说,您的代码正在工作,因为您正在使用引导程序3,所以您可能希望对图像使用img-responsive类,因为它的宽度很大。

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <link
      rel="stylesheet"
      href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css"
      integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu"
      crossorigin="anonymous"
    />
    <title>Static Template</title>
  </head>
  <body>
    <h1>
      This is a static template, there is no bundler or bundling involved!
    </h1>
  </body>
  <!-- Latest compiled and minified CSS -->
  <div class="container">
    <div class="wrapper">
      <div class="row">
        <div class="col-xs-3" style="background-color:pink;">
          <h3>Headline</h3>
          <p>Some text here</p>
          <button type="button" class="btn btn-info">Button</button>
        </div>
        <div class="col-xs-9">
          <img src="http://placehold.it/900x200" class="img-responsive" />
        </div>
      </div>
    </div>
  </div>

  <!-- Latest compiled and minified JavaScript -->
</html>

通过我将col-sm-3col-sm-9类更改为xs类的方式,您可能需要考虑将其更改为mdsm的情况。

© www.soinside.com 2019 - 2024. All rights reserved.