1

How can I have a full image background inside a column but without knowing the height of it? Im using bootstrap and I need the image to be responsive. Please look at the image for a better understanding

<div class="  col-xs-12 col-sm-5 col-md-5 col-lg-4 bgimage">
 </div>
 <div class="   col-xs-12 col-sm-7 col-md-7 col-lg-8">
</div>
with .bgimage
{
 background-image: url(../img/user.jpg);

    background-size: cover;

}
FerchoCarcho
  • 531
  • 8
  • 20

2 Answers2

0

Using background-size: cover; will cover the box without losing the ratio.

Using background-size: 100%; will fill the box but will losing the ratio.

EDIT

This is sample how the background works.

.table {
  display: table;
  width: 100%;
}

.cell {
  display: table-cell;
}
.cell.left {
  background-image: url(http://oi58.tinypic.com/2u9mo0g.jpg);
  background-size: cover;
}
.cell.right {
  width: 60%;
  padding: 80px 30px;
  background: #ccc;
}
<div class="table">
  <div class="cell left"></div>
  <div class="cell right">
    Lorem ipsum dolor sit amet
  </div>
</div>
0

here's a bootstrap example of a column that has background-size:cover

http://jsfiddle.net/maio/7rbjj2fn/3/

.bgimage{
    background-image: url(http://oi58.tinypic.com/2u9mo0g.jpg);
    background-size: cover;
    height:200px
}
.right{
    background:yellow;
    height:100%;
}
.row{
    background:tomato
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet"/>
<div class='row'>
<div class="  col-sm-5 col-md-5 col-lg-4 bgimage">
    </div>
    <div class="right col-sm-7 col-md-7 col-lg-8">
       Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa.  nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede mollis pretium. Integer tincidunt. Cras dapibus. Vivamus elementum semper nisi. Aenean vulputate eleifend tellus. Aenean leo ligula, porttitor eu, consequat vitae, eleifend ac, enim. Aliquam lorem ante, dapibus in, viverra quis, feugiat a, tellus. Phasellus viverra nulla ut metus varius laoreet. Quisque rutrum. Aenean imperdiet. Etiam ultricies nisi vel augue. Curabitur ullamcorper
maioman
  • 18,154
  • 4
  • 36
  • 42