【问题标题】:Responsive image with the same height as another column in the same row与同一行中的另一列具有相同高度的响应图像
【发布时间】:2017-06-24 02:47:08
【问题描述】:

我正在尝试将图像放置在表单的右侧,并且我需要图像与表单 div 的高度相同。在不扭曲图像的情况下,我很难做到这一点。

我使用的图像是 1920 X 1200。

我得到的代码如下:

<div class="container-fluid">
    <div class="row">
        <div class="col-xs-12 col-sm-4 govx-form">
            <div class="form-background">
                <?php echo do_shortcode(); ?>
                <?php echo do_shortcode(); ?>
            </div>
        </div>
        <div class="col-xs-12 col-sm-8 govx-form price-results"    id="ap_pricing_results">
            <img src="wp-content/images/fourHeroesLarger_edit.jpg" alt="" class="img-responsive">
        </div>
    </div>
</div>

我当然尝试使用 css 使高度与表单的高度匹配,但一旦我这样做,它就会破坏图像的响应能力。此外,当我设置高度时,我将宽度设置为 100% 以填充 div,但这会使图像失真非常糟糕。

我也尝试过使用以下 css 样式制作背景图片:

.price-results {
    background-image: url(/wp-content/images/fourHeros.jpeg);
    background-repeat: no-repeat;
    background-size: 335px;
    background-position: top;
    height: 130px;
}

这适用于较小的屏幕尺寸,但会再次破坏较大屏幕尺寸的图片。

【问题讨论】:

  • 尝试使用它作为背景图像,就像你做的那样,但使​​用background-size: cover;
  • 那也行不通。它不会扭曲图像,但会裁剪它。

标签: html css twitter-bootstrap responsive-design grid-layout


【解决方案1】:

你试过了吗:

.price-results {
background-image: url(/wp-content/images/fourHeros.jpeg) no-repeat;
background-size: 335px auto;
background-position: top;
}

另外,你有一个正在运行的网站吗?它可以帮助你弄清楚。

【讨论】:

    猜你喜欢
    • 2016-05-13
    • 1970-01-01
    • 2016-03-03
    • 2016-05-12
    • 2016-04-22
    • 2014-12-13
    • 2013-05-11
    • 1970-01-01
    • 2019-04-13
    相关资源
    最近更新 更多