I'm having a difficulty getting something to work in Bootstrap 3.3.7. Fiddle is here: https://jsfiddle.net/rrqt9e98/
<div class="container">
<div class="row">
<div class="col-md-6" style="background-color: red;">
<img src="http://placehold.it/500x333">
</div>
<div class="col-md-6" style="background-color: yellow;">
<p>
Content column
</p>
</div>
</div>
</div>
Output is currently like this:
What I'm trying to do is get my image (which has an original size of 500*333px) to occupy the full width of the left hand column. I've set width: 100%
in my CSS on the img
to achieve this, following advice given here: How do you stretch an image to fill a <div> while keeping the image's aspect-ratio?
I'm not sure why the red background colour behind the image appears, as I want the image flush with the col-md-6
edges. So I tried adding:
img {
padding: 0;
border: 0;
}
I also would like the right hand yellow column to match the height of the image. I am using the jQuery Match height plugin in my project, so could opt for that, unless there is a CSS solution.
The overall effect I would like is a 2 column layout where the image takes up the full left hand column, and that the right hand column matches the height of the left hand column. At a mobile breakpoint (sm
or lower) I would like to horizontally stack these 2 columns.
I want it to look like this (which I've mocked up in Fireworks just to show how it should look):
Please can someone point me in the right direction with this?