Bootstrap - mixing container and container-fluid - html

I'm currently building a site which is one of those tall pages broken up in to horizontal panels for each different section.
Some of the horizontal panels are fixed-width centred in the middle (see 1,2,3,5 in diagram) and some are full-width (see 4 in diagram). For the fixed-width I'm using a ".container" class and that's easy enough and working fine. For the full-width panels I'm using ".container-fluid".
Now the problem I'm facing is as follows (see image for reference.)
So panel 4 is full width and consists of 2 columns. The textual content is between B & C, and C & D, however there is 2 background images that span A to C and C to E and I can't figure out how to do that.
I've tried to split it in to 2 columns and then have a fixed width section in the middle but can't get it working. This is where I'm currently at:
<div class="container-fluid">
<div class="col-sm-6">
<img src="" />
<div class="container">
</div>
</div>
<div class="col-sm-6">
<img src="" />
<div class="container">
</div>
</div>
</div>
Any advice greatly appreciated.

EDIT: Added two-column split for container-fluid.
From what I understood from the image shown on your question, I would recommend separating the containers and naming them with classes or ID's in order to remove stock margins or others that push it down or up.
<div class="container topContainer">
<p>Content here</p>
</div>
<div class="container-fluid midContainer">
<div class="row">
<div class="col-sm-6 leftPad">
<div class="row">
<div class="col-sm-6">
<p>Content here</p>
</div>
<div class="col-sm-6">
<p>Content here</p>
</div>
</div>
</div>
<div class="col-sm-6 rightPad">
<div class="row">
<div class="col-sm-6">
<p>Content here</p>
</div>
<div class="col-sm-6">
<p>Content here</p>
</div>
</div>
</div>
</div>
</div>
<div class="container botContainer">
<p>Content here</p>
</div>
And for setting the background, use the following CSS:
.leftPad {
background-image: url('example.jpg');
}
.rightPad {
background-image: url('example2.jpg');
}
This should wrap it up, and keep it clean without messing anything. To adjust margins and other placements, implement some CSS to those custom classes I've set up on the example.
As a tip I would say that do not use container inside a row or column. Wrap the whole page inside a column and separate the content itself with rows and cols to suite your needs.
Happy coding!

Found few solutions, but all used javascript. So here's my css-only solution. Cheers :)
/* just some styling for better view */
#mix {
background: black;
color: #fff;
}
.left {
background: url('https://static.pexels.com/photos/462254/pexels-photo-462254.jpeg') no-repeat center / cover;
}
.right {
background: url('https://static.pexels.com/photos/534020/pexels-photo-534020.jpeg') no-repeat center / cover;
}
.row {
border-top: 1px solid black;
}
.col-sm-6 {
padding-top: 15px;
padding-bottom: 15px;
}
/* and this below is basically what you need */
#media (min-width: 768px) {
.half-container {
padding-left: 15px;
padding-right: 15px;
max-width: 375px;
}
.left-half-container {
margin-right: -15px;
}
.right-half-container {
margin-left: -15px;
}
}
#media (min-width: 992px) {
.half-container {
max-width: 485px;
}
}
#media (min-width: 1200px) {
.half-container {
max-width: 585px;
}
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<div id="mix">
<div class="container">
<div class="row">
<div class="left col-sm-6">
<div class="text-justify">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure
dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</div>
</div>
<div class="right col-sm-6">
<div class="text-justify">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure
dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</div>
</div>
</div>
</div>
<div class="container-fluid">
<div class="row">
<div class="left col-sm-6 clearfix">
<div class="half-container left-half-container pull-right text-justify">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure
dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</div>
</div>
<div class="right col-sm-6 clearfix">
<div class="half-container right-half-container pull-left text-justify">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure
dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</div>
</div>
</div>
</div>
</div>

Below is the structure and use images as a background images of container-fluid div
<div class="container-fluid">
<div class="container">
<div class="col-sm-6"> </div>
<div class="col-sm-6"> </div>
</div>
</div>

Related

bootstrap Content finalized

When I use the bootstrap to content layout, if the picture is on the left, it seems to be adaptive. If I put the picture on the right, it is different from the original. How can I control it?
<div class="about" id="about">
<div class="container">
<h1 class="text-center">About Me</h1>
<div class="row">
<div class="col-lg-4 col-md-4 col-sm-12">
<img src="img/120.png" class="img-fluid">
</div>
<div class="col-lg-8 col-md-8 col-sm-12 desc">
<h3>D.John</h3>
<p>
ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim
veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea
commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit
esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat
cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est
laborum.
</p>
</div>
</div>
</div>
</div>
<div class="about" id="about">
<div class="container">
<h1 class="text-center">About Me</h1>
<div class="row">
<div class="col-lg-4 col-md-4 col-sm-12 ">
<h3>D.John</h3>
<p>
ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim
veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea
commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit
esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat
cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est
laborum.
</p>
</div>
</div>
</div>
</div>
As you can see here it effects images.
.about{
margin: 4em 0;
padding: 1em;
position: relative;
}
.about h1{
color:#F97300;
margin: 2em;
}
.about img{
height: 100%;
width: 100%;
border-radius: 50%
}
.about span{
display: block;
color: #888;
position: absolute;
left: 115px;
}
.about .desc{
padding: 2em;
border-left:4px solid #10828C;
}
.about .desc h3{
color: #10828C;
}
.about .desc p{
line-height:2;
color:#888;
}
If I put the picture on the right, it is different from the original - how can I control this behaviour?
<div class="about" id="about">
<div class="container">
<h1 class="text-center">About Me</h1>
<div class="row">
<div class="col-lg-4 col-md-4 col-sm-12">
<img src="http://commondatastorage.googleapis.com/codeskulptor-assets/lathrop/nebula_brown.png"
class="img-fluid">
</div>
<div class="col-lg-8 col-md-8 col-sm-12 desc">
<h3>D.John</h3>
<p>
ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim
veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea
commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit
esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat
cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est
laborum.
</p>
</div>
</div>
</div>
</div>
<div class="about" id="about">
<div class="container">
<h1 class="text-center">About Me</h1>
<div class="row">
<div class="col-lg-8 col-md-8 col-sm-12 order-1">
<img src="http://commondatastorage.googleapis.com/codeskulptor-assets/lathrop/nebula_brown.png"
class="img-fluid">
</div>
<div class="col-lg-4 col-md-4 col-sm-12 ">
<h3>D.John</h3>
<p>
ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim
veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea
commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit
esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat
cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est
laborum.
</p>
</div>
</div>
</div>
</div>
Try this code
You can mange the layout through order option.
Change the div classes like:
<div class="col-lg-8 col-md-8 col-sm-12 desc">
to
<div class="col-lg-4 col-md-4 col-sm-12 ">
its ok.

Sections overlapping Bootstrap 4

I have a problem with two sections of my website, up to a certain size they are separated
but in the smallest size they overlap
Here is part of my code:
.home-inner {
height: 100vh;
width: 100vw;
background-image: url('../img/bg.jpg');
background-position: center;
background-size: cover;
background-repeat: no-repeat;}
.caption {
width: 100%;
max-width: 100%;
position: absolute;
top: 38%;
z-index: 1;
text-transform: uppercase;}
<section id="inicio">
<div class="landing">
<div class="home-wrap">
<div class="home-inner">
</div>
</div>
</div>
<div class="caption text-center">
<h1>Title</h1>
<h3>Sub title</h3>
VER PRODUCTOS
</div>
</div>
</section>
<section class="qsomos">
<div id="bio" class="container-fluid">
<div class="row justify-content-center align-items-center">
<div class="col-lg-5 col-xs-3 mx-auto">
<h2>TÍTULO</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. <br>Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
</div>..........
In the images you can see what I mean, I'm a beginner so I'm grateful that someone can help me with something this simple.
What you'll need to do is add media queries to your CSS. Media queries can alter your CSS based on the screen size/device so that when the screen size is smaller your HTML will adjust to the screen size.
Take a look at this for further reference:
https://www.w3schools.com/css/css_rwd_mediaqueries.asp

Position two images and make them look nice on mobile, the images does not have equal sizes

This is my fiddle Fiddle
I am trying to achieve the following:
Two images that are not the same size should stay side by side in a full-width container and should keep the same height. (it works on my computer resolution = 1388px width), but at different resolutions the images won't have the same height.
On smaller resolution (for example less than 991px) the images will go one under another one (like it can be seen in the fiddle, but the issue here is that there is a space between images and the writing will not fit the second image height.
The last thing is: the writing in the second image (on desktop resolutions for example greater than 991px) should end exactly where the writing of the above paragraph ends. (the paragraph is in a bootstrap container)
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" rel="stylesheet" />
<div class="container-fluid nopadding">
<section id="about-us">
<div class="col-lg-5 col-md-12 nopadding">
<div class="background-image-left">
<img src="http://placehold.it/2400x1600" class="img-responsive" />
</div>
</div>
<div class="col-lg-7 col-md-12 nopadding">
<div class="background-image-right" style="background:url('http://placehold.it/1920x481;') center center no-repeat">
<div class="inner">
<h2>About us</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
<p>Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
</div>
</div>
</div>
</section>
</div>
I need to keep these images at this size.
You can add both images as background images. Also both of your div's having the background image need to have fixed equal height.
<div class="row">
<div class="col-lg-5 col-md-12 nopadding">
<div class="background-image-left">
</div>
</div>
<div class="col-lg-7 col-md-12 nopadding">
<div class="background-image-right">
<div class="inner">
<h2>About us</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
<p>Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
</div>
</div>
</div>
</div>
And the CSS
.background-image-left, .background-image-right {
height: 500px;
background-size: cover;
background-position: center center;
}
.background-image-left {
background: url('http://placehold.it/2400x1600');
}
.background-image-right {
background: url('http://placehold.it/1920x481');
}

separating columns within a div for left alignment of text (bootstrap)

i'm thinking this will be simple, but i cant get my head round it!
The main "Lorem Ipsum" text paragraph in the screenshot i would like to only fill the left half of the box that its in. When i try and put a div within the main div to do this, it aligns left but the box doesn't expand downwards with the text so it "over spills".
Screenshot
http://i772.photobucket.com/albums/yy4/philbuckthorpe/Screen%20Shot%202016-09-26%20at%2020.51.00_zpshcjcm6qh.png
.thumbnail {
padding: 0;
}
.thumbnail .caption-full {
padding: 9px;
color: #333;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container">
<div class="row">
<div class="col-md-3">
<p class="lead">Our Artists</p>
<div class="list-group">
Artist 1
Artist 2
Artist 3
</div>
</div>
<div class="col-md-9">
<div class="thumbnail">
<img class="img-responsive" src="http://placehold.it/800x300" alt="">
<div class="caption-full">
<h4>Artist 1
</h4>
<p>Want to know when "Artist 1" will next be performing live? CLick this link <a target="_blank" href="#">website here</a>.</p>
<p><strong>About "Artist 1"</strong></p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum</p>
</div>
</div>
</div>
</div>
</div>
The issue can only be seen on wider displays and not on mobile sized displays. To put it into context i want the main paragraph to take the left half of the box its in, so i can embed a Spotify playlist in the right hand half of the box.
All help is much appriciated. Happy to buy someone a coffee that can help.
So i figured this out, i needed to add a <div class="row"> underneath the <div class="caption-full"> and then use new divs to seperate the left and the right of this new row.
Example of the code that fixed my issue (its not neat yet):
.thumbnail {
padding: 0;
}
.thumbnail .caption-full {
padding: 9px;
color: #333;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<div class="container">
<div class="row">
<div class="col-md-3">
<p class="lead">Our Artists</p>
<div class="list-group">
Artist 1
Artist 2
Artist 3
</div>
</div>
<div class="col-md-9">
<div class="thumbnail">
<img class="img-responsive" src="http://placehold.it/800x300" alt="">
<div class="caption-full">
<div class="row">
<div class="col-md-7">
<h4>Artist 1
</h4>
<p>Want to know when "Artist 1" will next be performing live? CLick this link <a target="_blank" href="#">website here</a>.</p>
<p><strong>About "Artist 1"</strong>
</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute
irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum</p>
</div>
<div class="col-md-5">
<p>irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum</p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>

From one-third columns to one-half colums

I am trying to make a list of images and descriptions that are in sets of threes at larger widths, and go to sets of twos at smaller widths. But when I break down it gets very messed up, and I don't know what to do to make it break down into clean one-half columns. Thanks in advance for your help!
div.thirds {
padding-bottom: 20px;
padding: 50px;
text-align: center;
font-family: Gudea;
}
div.button1 {
width:90px;
height:40px;
margin-left: 38%;
}
div.one-third {
width: 30%;
float: left;
margin-right: 5%;
text-align: center;
font-family: Gudea;
}
div.button2 {
width:90px;
height:40px;
margin-left: 38%;
}
div.one-third-last {
margin: 0;
text-align: center;
font-family: Gudea;
}
div.button3 {
width:90px;
height:40px;
margin-left: 38%;
}
#media (maxwidth:900px;)
div.one-third {
width: 47.5%;
}
div.one-third-second {
margin: 0;
}
div.one-third-last {
clear: both;
float: none;
width: auto;
padding: 20px 0 0 0;
}
div.one-third {
width: 47.5%;
}
div.one-third-second {
margin: 0;
}
div.one-third-last {
clear: both;
float: none;
width: auto;
padding: 20px 0 0 0;
}
<div class="thirds clearfix">
<!-- one-third -->
<div class="one-third mobile-collapse">
<img src="http://29.media.tumblr.com/tumblr_lvh3v78jGD1r2lhkno1_500.jpg" alt="A bird on a fence" />
<h2>The Trainer</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<div class="button1">
<img src="http://i66.tinypic.com/33kakow.png">
</div>
</div><!--/one-third-->
<!-- one-third -->
<div class="one-third one-third-second mobile-collapse">
<img src="http://29.media.tumblr.com/tumblr_lvh3v78jGD1r2lhkno1_500.jpg" alt="A bird eating" />
<h2>Lessons</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<div class="button2">
<img src="http://i66.tinypic.com/33kakow.png">
</div>
</div><!--/one-third-->
<!-- one-third -->
<div class="one-third one-third-fourth mobile-collapse">
<img src="http://29.media.tumblr.com/tumblr_lvh3v78jGD1r2lhkno1_500.jpg" alt="A cat" />
<h2>Training</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<div class="button3">
<img src="http://i66.tinypic.com/33kakow.png">
</div>
</div><!--/one-third-->
</div><!--/thirds-->
<!-- thirds -->
<div class="thirds clearfix">
<!-- one-third -->
<div class="one-third mobile-collapse">
<img src="http://29.media.tumblr.com/tumblr_lvh3v78jGD1r2lhkno1_500.jpg" alt="A bird on a fence" />
<h2>The Trainer</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<div class="button1">
<img src="http://i66.tinypic.com/33kakow.png">
</div>
</div><!--/one-third-->
<!-- one-third -->
<div class="one-third one-third-second mobile-collapse">
<img src="http://29.media.tumblr.com/tumblr_lvh3v78jGD1r2lhkno1_500.jpg" alt="A bird eating" />
<h2>Lessons</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<div class="button2">
<img src="http://i66.tinypic.com/33kakow.png">
</div>
</div><!--/one-third-->
<!-- one-third -->
<div class="one-third one-third-last mobile-collapse">
<img src="http://29.media.tumblr.com/tumblr_lvh3v78jGD1r2lhkno1_500.jpg" alt="A cat" />
<h2>Training</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<div class="button3">
<img src="http://i66.tinypic.com/33kakow.png">
</div>
</div><!--/one-third-->
</div>
I'm sure your problem is around mixing percentage and fixed values. Try and think in terms of having 100% to play with. If you for example have a width of 48% with a fixed margin of say 100px, what happens if 100px is bigger than the 2% you have left to play with. Problems. That's what.
Are you allowed to use CSS Flex? If it fits in your minimum level of required CSS browser support, it could really save you a lot of the headache you're currently dealing with trying to manage floats.
CSS
.flex {
display: flex;
}
.wrap {
flex-wrap: wrap;
}
.item {
width: 33%;
}
#media (max-width: 900px) {
.item {
width: 50%;
}
}
HTML
<div class="flex wrap">
<div class="item">Item 1</div>
<div class="item">Item 2</div>
<div class="item">Item 3</div>
<div class="item">Item 4</div>
<div class="item">Item 5</div>
<div class="item">Item 6</div>
</div>
You can expand the example to include additional markup inside each .item class. I provide a larger example here - JSFiddle
bootstrap is the way to go - the following will display 2 rows of 3 divs on a medium to large viewport. 3 rows of 2 divs on a small viewport. Note that there is a col-lg class as well if you want to have another style for large screens and a col-sm class if you want a class between mobile size (xs) and small screen (sm), also I have not inserted the OP code into the divs - I just wanted to demonstrate the point:
click the full screen link in the following snippet to see the div's change position depending on the width of the viewport. I also added a border to each and centered the text - just for demonstration purposes.
.container div{
text-align:center;
border:solid 1px #ddd}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
<div class="container">
<div class="col-md-4 col-xs-6">Content</div>
<div class="col-md-4 col-xs-6">Content</div>
<div class="col-md-4 col-xs-6">Content</div>
<div class="col-md-4 col-xs-6">Content</div>
<div class="col-md-4 col-xs-6">Content</div>
<div class="col-md-4 col-xs-6">Content</div>
</div>