divs won't horizontally align in CSS - html

So I am having trouble aligning 3 divs that are circles on my page.
Here is the HTML
<div class="row">
<div class="large-9 push-2 columns">
<div class="green"></div>
Donnez
</div>
<div class="row">
<div class="large-9 push-4 columns">
<div class="cyan"></div>
Recevez
</div>
</div>
<div class="row">
<div class="large-9 push-6 columns">
<div class="orange"></div>
Statistique
</div>
</div>
</div>
Here is the CSS :
.green, .cyan, .orange {
border-radius: 50%;
width: 15px;
height: 15px;
position: relative;
float: left;
}
.green {
background: #40b564;
}
.cyan {
background: #61cfcc;
}
.orange {
background: #f8765c;
}
Here is what it looks like :
http://4.ii.gl/V0DOyL.png
I basically want the 3 circles (3 divs) to be aligned properly horizontally. Now I have tried display : inline-block; and other things but nothing seems to work. I don't know if this has anything to do with the fondation framework ? I have been trying to figure this out for hours now, any help would be greatly appreciated !

You have them in seperate class="rows" that is why they are in seperate lines.
You have to place them in one Row.
<div class="row">
<div class="large-4 columns">
<div class="green"></div>
Donnez
</div>
<div class="large-4 columns">
<div class="green"></div>
Donnez
</div>
<div class="large-4 columns">
<div class="green"></div>
Donnez
</div>
</div>
Try this in your code, upload a new snapshot, I will see if I can help anymore.
Another Mistake I noticed is that (Not Related to your current layout):
<div class="large-9 push-6 columns">
<div class="orange"></div>
Statistique
</div>
You are doing large-9 push-6, the total should not be more than 12. In you case it is 9+6=15, it should be like large-9 push-3, large-8 push-4 or large-6 push-6 so that total is always 12

Related

Bootstrap columns overlapping on small screens

I have 2 columns and on the left and the right side, When I open the web page on a small or xs screen the two columns overlap. I would like for the other column to go below the other.
<div class="container">
<div class="row">
<div class="col-md-3"></div>
<div class="col-md-9 area-style"></div>
</div>
</div>
CSS:
.area-style {
border: 1px solid #ccc;
padding-top: 2em;
background: #fafafa;
height: 500px;
}
Please check if you have given floats to the elements inside any of the "col-md-3" or "col-md-9" divs. The Overlapping 99% occurs If the floats are not cleared.
If you are using Bootstrap4 try this.
<div class="container">
<div class="row">
<div class="col-12 col-md-3"></div>
<div class="col-12 col-md-9 area-style"></div>
</div>
</div>
Try this.
<div class="container">
<div class="row">
<div class="col-xs-12 col-md-3"></div>
<div class="col-xs-12 col-md-9 area-style"></div>
</div>
</div>
Please tell me if this helps you.

How to stack Bootstrap row inside of another row?

I have a Bootstrap page on which I'm trying to stack different boxes.
Imgur - Image of boxes (sorry, not enough rep to upload images directly)
The green boxes are the ones currently in position, and the red ones are the ones I am having issues with. I'm using the following code (simplified) to get the green boxes:-
<div class="container">
<div class="row">
<div class="col-xs-3" style="height:100px; background-color:green;">
</div>
<div class="col-xs-3" style="height:100px; background-color:green;">
</div>
<div class="col-xs-6" style="height:200px; background-color:green;">
</div>
</div>
</div>
I'm basically trying to create another two <div class="col-xs-3" style="height:100px; background-color:green;"> that will go underneath the current two, while also keeping the large box to the right.
I thought it would be an easy fix with a new row, or using float:left / right, but none of that seems to be working out.
One way to do it would be to make two 50% width columns and then divide the column on the right into two rows with two more columns in each:
.green-lrg {
background-color:green;
height:215px;
}
.green-sml {
background-color:green;
height:100px;
}
.red-sml {
background-color:red;
height:100px;
}
.col-xs-6 .row {
padding-top:15px;
}
.col-xs-6 .row:first-child {
padding-top:0;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container">
<div class="row">
<!-- LEFT COLUMN -->
<div class="col-xs-6">
<div class="green-lrg"></div>
</div>
<!-- RIGHT COLUMN -->
<div class="col-xs-6">
<div class="row">
<div class="col-xs-6">
<div class="green-sml"></div>
</div>
<div class="col-xs-6">
<div class="green-sml"></div>
</div>
</div>
<div class="row">
<div class="col-xs-6">
<div class="red-sml"></div>
</div>
<div class="col-xs-6">
<div class="red-sml"></div>
</div>
</div>
</div>
</div>
</div>
Here is simple example.
HTML
<div class="container">
<div class="row">
<div class="col-xs-6 box box-big">
</div>
<div class="col-xs-6">
<div class="row">
<div class="col-xs-6 box box-small">
</div>
<div class="col-xs-6 box box-small">
</div>
<div class="col-xs-6 box box-small">
</div>
<div class="col-xs-6 box box-small">
</div>
</div>
</div>
</div>
</div>
and CSS:
.box {
background-color:green;
border:5px solid white;
}
.box-big {
height:200px;
}
.box-small {
height:100px;
}

How can I build a nested grid of photos in Foundation?

JSFiddle: https://jsfiddle.net/s0m142c4/
I am trying to use foundation's grid to build a grid of photos.
I want it to look like this with all of the blocks representing photos.
:
I am, as foundation's documentation suggests, nesting two columns inside of one column, and the third column just contains its image.
HTML:
<div class="row grid-row">
<div class="large-6 columns">
<div class="row">
<div class="large-12 columns grid-img port">
<img src="img/tile1-new.jpg" />
</div>
</div>
</div>
<div class="large-6 columns">
<div class="row">
<div class="large-4 columns grid-img land">
<img src="img/tile7.jpg" />
</div>
<div class="large-4 columns grid-img land">
<img src="img/tile3.jpg" />
</div>
</div>
<div class="row">
<div class="large-4 columns grid-img">
<img src="img/tile7.jpg" />
</div>
<div class="large-4 columns grid-img">
<img src="img/tile3.jpg" />
</div>
</div>
</div>
</div>
CSS:
.grid-img{
text-align: center;
}
.grid-img img{
min-width:90%;
}
.grid-img.port img{
min-width:100%;
}
.grid-row{
height:600px;
}
But it's coming out like this instead:
Any idea how to get the images to fill their nested columns and maintain a padded grid like my example?
This is very close, you needed to use 100% width for the images and then change large-4 columns to large-6 as they were never going to take up 50% each which they needed to do.
You can now tweak bottom margin to make the layout work a little bit better. There's a really geeky way to do this which is Masonry.js or Isotope.js, it resizes containers, but might be a bit heavy handed to do what html and css can do pretty well. See below:
/*.grid-img {
text-align: center;
}
.grid-img img {
min-width: 90%;
}
.grid-img.port img {
min-width: 100%;
}
.grid-row {
height: 600px;
}
*/
.grid-img img {
width: 100%;
margin-bottom: 2em;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/foundation/6.0.0/foundation.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/foundation/6.0.0/foundation.min.css" rel="stylesheet" />
<div class="row grid-row">
<div class="large-6 columns">
<div class="row">
<div class="large-12 columns grid-img port">
<img src="http://placehold.it/600x600" />
</div>
</div>
</div>
<div class="large-6 columns">
<div class="row">
<div class="large-6 columns grid-img land">
<img src="http://placehold.it/600x600" />
</div>
<div class="large-6 columns grid-img land">
<img src="http://placehold.it/600x600" />
</div>
</div>
<div class="row">
<div class="large-6 columns grid-img">
<img src="http://placehold.it/600x600" />
</div>
<div class="large-6 columns grid-img">
<img src="http://placehold.it/600x600" />
</div>
</div>
</div>
</div>

Container alignment to the edge of browser window

I have a div that goes to the edge with the browser and would ilke to add content that is aligned to the centered container in the center of the page. I've crated a row with a col-md-6 that I filled with a background color but when I add the container, the content gets aligned to the edge of the browser not to the container's edge.
I am using Bootstrap and really need your help. If I did not articulate the issue properly, I've attached an image that should help.
Thanks for your help.
.login-msg-box {
background: rgba(0,0,0,0.5);
margin-top: 200px;
height: 400px;
}
<div class="row">
<div class="col-md-6 login-msg-box">
<div class="container">
<h2 class="msg-heading-line">LOG IN</h2>
</div>
</div>
</div>
Image shows the current situation and the desired situation
As you did a margin-top for the .login-msg-box, you could for example add a margin-left to your .container. Here's the result :
.login-msg-box {
background: rgba(0,0,0,0.5);
margin-top: 200px;
height: 400px;
}
.container {
margin-left: 200px;
}
<div class="row">
<div class="col-md-6 login-msg-box">
<div class="container">
<h2 class="msg-heading-line">LOG IN</h2>
</div>
</div>
</div>
You can add any number of offset to div
<div class="row">
<div class="col-md-6 col-md-offset-6 login-msg-box">
<div class="container">
<h2 class="msg-heading-line">LOG IN</h2>
</div>
</div>
</div>
I think you are looking for something like this https://jsfiddle.net/neya0v76/1/
I switch everything to xs so it looks right in the fiddle and just restructered your html
<div class="row">
<div class="col-xs-6 login-msg-box">
<div class="row">
<div class="col-xs-6">
</div>
<div class="col-xs-6">
<h2 class="msg-heading-line">LOG IN</h2>
<input type="text"/>
<input type="text"/>
</div>
</div>
</div>

Layout issue with Grids:SkeletonFramework

I am using Skeleton Framework, and the layout I made using the grid system is like this:
<div class="container">
<!-- columns should be the immediate child of a .row -->
<div class="row">
<div class="three columns">
<br>
</div>
<div class="six columns" style="margin-top: 25px">
<img src="img/okay.jpg" width="50px" style="display:inline"/>
<p id="title" style="display:inline">{{title}}</p>
<p id="excerpt" style="display:inline">{{description}}</p>
<div id="describe me" style="display:inline"><span style="display:inline">{{name}}</span><span style="display:inline">{{date}}</span></div>
</div>
<div class="three columns">
<br>
</div>
</div>
</div>
It shows something like this:
But what I want is something like this:
How can this be achieved?
Result:
Responding to your code, although there are many alternate solutions for this, maybe even in their documentation.
First, try to avoid using inline styles.
Wrap your content inside a
class.
Vetical align the image to the top.
Remove the default margin
on the paragraph items.
.desc {
display: inline-block;
}
.desc p {
margin-bottom: 0;
}
.six img {
vertical-align: top;
}
<link href="//cdnjs.cloudflare.com/ajax/libs/skeleton/2.0.4/skeleton.min.css" rel="stylesheet" />
<div class="container">
<!-- columns should be the immediate child of a .row -->
<div class="row">
<div class="three columns">
<br>
</div>
<div class="six columns">
<img src="http://placehold.it/50x75" width="50px" />
<div class="desc">
<p id="title">{{title}}</p>
<p id="excerpt">{{description}}</p>
<div id="describe me"><span>{{name}}</span><span>{{date}}</span>
</div>
</div>
</div>
<div class="three columns">
<br>
</div>
</div>
</div>