Reputation: 129
When using col-sm-6 I can not align the picture and the box-text. I am not sure if it is a problem of image or margin/padding etc.
html:
/* css: */
.category {
padding-top: 3rem;
padding-bottom: 3rem;
background-color: #096;
}
.categoryimg {
display: block;
height: 487px;
max-width: 100%;
}
.categorytext {
padding-top: 12%;
font-family: Avenir;
color: #0670EB;
font-weight: bold;
background-color: white;
width: 50%;
height: 487px;
float: right;
}
.categorytext1 {
padding-top: 12%;
font-family: Avenir;
color: #0670EB;
font-weight: bold;
background-color: white;
width: 50%;
height: 487px;
float: left;
}
<div class="container-fluid">
<div class="container">
<div class="row">
<div class="col-sm-6 categorytext1">
<h2>LANGUAGE</h2>
<p class="lead">Nibook is a platform where foreigners can change their frame time into money by crafting beautiful services and share them with the locals within in-person or online experiences.</p>
</div>
<div class="col-sm-6"> <img src="img/language.png" class="categoryimg" alt="Generic placeholder image"> </div>
</div>
</div>
</div>
</div>
Next picture is what I try to achieve. I try to put 1 img and 1 text box by row and make it as a table with padding between each boxed. I am not sure how to resolve this issue.
Upvotes: 0
Views: 728
Reputation: 327
Use this code:
<div class="container-fluid">
<div class="container">
<div class="row">
<div class="col-sm-6 pad0">
<img src="http://ingridwu.dmmdmcfatter.com/wp-content/uploads/2015/01/placeholder.png" class="categoryimg" alt="Generic placeholder image">
</div>
<div class="col-sm-6 pad0">
<div class="categorytext1">
<h2>LANGUAGE</h2>
<p class="lead">Nibook is a platform where foreigners can change their frame time into money by crafting beautiful services and share them with the locals within in-person or online experiences.</p>
</div>
</div>
</div>
<div class="row">
<div class="row">
<div class="col-sm-6 col-sm-push-6 pad0">
<img src="http://ingridwu.dmmdmcfatter.com/wp-content/uploads/2015/01/placeholder.png" class="categoryimg" alt="Generic placeholder image">
</div>
<div class="col-sm-6 col-sm-pull-6 pad0">
<div class="categorytext1">
<h2>LANGUAGE</h2>
<p class="lead">Nibook is a platform where foreigners can change their frame time into money by crafting beautiful services and share them with the locals within in-person or online experiences.</p>
</div>
</div>
</div>
</div>
</div>
<style>
body{
background: #f5f5f5;
}
.pad0{
padding: 5px;
margin-bottom: 5px;
}
.category {
padding-top: 3rem;
padding-bottom: 3rem;
background-color: #096;
}
.categoryimg {
display:block;
height:487px;
max-width:100%;
}
.categorytext1 {
padding: 0 15px;
padding-top:12%;
font-family: Avenir;
color:#0670EB;
font-weight:bold;
background-color:white;
height:487px;
float:left;
}
</style>
Upvotes: 2
Reputation: 78
.categorytext1
is changing the width of the div, that is most likely messing with the bootstrap style for col-sm-6
.categorytext1 {
padding-top:12%;
font-family: Avenir;
color:#0670EB;
font-weight:bold;
background-color:white;
*****width:50%;*****
height:487px;
float:left;
}
Upvotes: 0