最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - make div background image responsive with bootstrap 3 - Stack Overflow

programmeradmin2浏览0评论

How make div with background image responsive with bootstrap 3 ??

Is it possible with img-responsive class in bootstrap 3 ??

My div is empty like below:

<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>

How make div with background image responsive with bootstrap 3 ??

Is it possible with img-responsive class in bootstrap 3 ??

My div is empty like below:

<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>
Share Improve this question edited Nov 3, 2013 at 12:17 b24 asked Nov 3, 2013 at 12:06 b24b24 2,4737 gold badges32 silver badges52 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 9

I think its not the case to use img-responsive here, since it was for <img />

and for making the div background image responsive, we can use 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. or if you want to stretch the background-image with resize in the div, use background-size: 100% 100%.

For more info on background-size CSS property go through this link.

发布评论

评论列表(0)

  1. 暂无评论