简体   繁体   English

使用bootstrap 3使div背景图像响应

[英]make div background image responsive with bootstrap 3

How make div with background image responsive with bootstrap 3 ?? 如何让div与背景图像响应bootstrap 3?

Is it possible with img-responsive class in bootstrap 3 ?? 是否可以在bootstrap 3中使用img-responsive类?

My div is empty like below: 我的div是空的,如下所示:

<div class="row">
    <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
        <div class="workflowstep workflowstep1 img-responsive">&nbsp;
        </div>
        <div class="workflowstep workflowstep2 img-responsive">&nbsp;
        </div>
        <div class="workflowstep workflowstep3 img-responsive">&nbsp;
        </div>
        <div class="workflowstep workflowstep4 img-responsive">&nbsp;
        </div>
        <div class="workflowstep workflowstep5 img-responsive">&nbsp;
        </div>
        <div class="workflowstep workflowstep6 img-responsive">&nbsp;
        </div>
    </div>
</div>

I think its not the case to use img-responsive here, since it was for <img /> 我认为这不是在这里使用img-responsive的情况,因为它是用于<img />

and for making the div background image responsive, we can use background-size: cover; 为了使div背景图像响应,我们可以使用background-size: cover;

background-size: cover; 背景尺寸:封面;

Scale the image, while preserving its intrinsic aspect ratio (if any), to the smallest size such that both its width and its height can completely cover the background positioning area 缩放图像,同时保持其固有的宽高比(如果有的话),使其最小尺寸,使其宽度和高度都可以完全覆盖背景定位区域

To make background-image responsive, you can use background-size: cover CSS property. 要使背景图像响应,您可以使用background-size: cover CSS属性。 or if you want to stretch the background-image with resize in the div, use background-size: 100% 100% . 或者如果要在div中调整大小来拉伸背景图像,请使用background-size: 100% 100%

For more info on background-size CSS property go through this link . 有关background-size CSS属性的更多信息,请通过此链接

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM