I’m having some trouble with displaying an image next to text using Twitter Bootstrap. I have the following HTML code:
<div class="panel panel-primary panel-projects">
<div class="panel-heading">
<h3 class="panel-title">Marijuana, Beer, and Wine Markets</h3>
</div>
<div class="panel-body">
<div class="row">
<img class="project-image col-md-4 center-block img-responsive" src="/images/project_wine.jpg"></img>
<p class="body-text col-md-8">
My content
</p>
</div>
</div>
</div>
And the following CSS:
.panel-projects {
margin: 35px;
}
.panel-body{
min-height: 235px;
}
.body-text{
font-size: 16px;
margin: 5px;
}
.project-image{
width: 300px;
height: auto;
text-align: center;
}
When the screen is full sized, the result is as expected: (W: 1366)
However, when the screen size is reduced just a little bit, there’s this stacking issue (W: 1199)
After resizing down a little bit more, I get this – which looks fine (W: 991)
How can I get the third style to trigger sooner, so that the awkward stacking layout doesn’t occur?
4
Answers
Rather use
col-lg
instead ofcol-md
I posted your code here: http://jsfiddle.net/6xq7omfp/
You will try this might be this will resolved your issues.
You can add image in p tag before content start : Like that way
Remove margin from “body-text” as margin will also count in CSS Box-Model.
Instead use padding.
You should have your
columns
separate from the other classes your’re adding: use thecolumns
by surrounding your content.You also have a closing
img
tag which isn’t necessary.<img />
col-md-4
img
col-md-8
See example Snippet.