0

I am using Bootstrap to create a grid layout. I have made a row with some columns in it and the columns have their background images. The problem is that when I shrink the screen size, The images get clipped.

<div class="col-md-2 col-sm-2 col-xs-2" style="background: url(img/days.png) no-repeat; background-size: auto 100%; background-
                        position: center center; max-width: 100%;">
    <div class="days_dash">
        <div class="digit">
            <div class="top" style="display: none;">8</div>
            <div class="bottom" style="display: block;">8</div>
        </div>
        <div class="digit">
            <div class="top" style="display: none;">3</div>
            <div class="bottom" style="display: block;">3</div>
        </div> <span class="dash_title">days</span>

    </div>
</div>
<!-- /Days -->
<div class="col-md-1 col-sm-1 col-xs-1"></div>
<!-- Hours -->
<div class="col-md-2 col-sm-2 col-xs-2" style="background: url(img/hours.png) no-repeat; background-size: auto 100%; background-position: center center;">
    <div class="hours_dash">
        <div class="digit">
            <div class="top" style="display: none;">2</div>
            <div class="bottom" style="display: block;">2</div>
        </div>
        <div class="digit">
            <div class="top" style="display: none;">0</div>
            <div class="bottom" style="display: block;">0</div>
        </div> <span class="dash_title">hours</span>

    </div>
</div>
<!-- /Hours -->
<div class="col-md-1 col-sm-1 col-xs-1"></div>
<!-- Minutes -->
<div class="col-md-2 col-sm-2 col-xs-2" style="background: url(img/minutes.png) no-repeat; background-size: auto 100%; background-position: center center;">
    <div class="minutes_dash">
        <div class="digit">
            <div class="top" style="display: none;">3</div>
            <div class="bottom" style="display: block;">3</div>
        </div>
        <div class="digit">
            <div class="top" style="display: block; overflow: hidden; height: 26.97222222222222px; padding-top: 0px; margin-top: 0px; padding-bottom: 0px; margin-bottom: 0px;">6</div>
            <div class="bottom" style="display: block; overflow: hidden; height: 38.62196180555556px;">7</div>
        </div> <span class="dash_title">minutes</span>

    </div>
</div>
<!-- /Minutes -->
<div class="col-md-1 col-sm-1 col-xs-1"></div>
<!-- Seconds -->
<div class="col-md-2 col-sm-2 col-xs-2" style="background: url(img/seconds.png) no-repeat; background-size: auto 100%; background-position: center center;">
    <div class="seconds_dash">
        <div class="digit">
            <div class="top" style="display: block; overflow: hidden; height: 37.4375px; padding-top: 0px; margin-top: 0px; padding-bottom: 0px; margin-bottom: 0px;">5</div>
            <div class="bottom" style="display: block; overflow: hidden; height: 27.9931640625px;">0</div>
        </div>
        <div class="digit">
            <div class="top" style="display: block; overflow: hidden; height: 37.4375px; padding-top: 0px; margin-top: 0px; padding-bottom: 0px; margin-bottom: 0px;">9</div>
            <div class="bottom" style="display: block; overflow: hidden; height: 27.9931640625px;">0</div>
        </div> <span class="dash_title">seconds</span>

    </div>
</div>
<!-- /Seconds -->
<div class="col-md-1 col-sm-1 col-xs-1"></div>

How can I stop it from not getting clipped but get more smaller?

Here's a fiddle.

Mohammad Areeb Siddiqui
  • 9,795
  • 14
  • 71
  • 113

1 Answers1

0

You can have the background-image automatically resize with background-size: contain.

Fiddle here: http://jsfiddle.net/Pm2nh/2/

Praxis Ashelin
  • 5,137
  • 2
  • 20
  • 46