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

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>

Related

Mobile Responsive section

I have a bit of an issue with a site I am creating. I need an alternative of float: left; for these icons. below I will upload two screenshots of the mobile screen and the computer screen.
Computer Size
Mobile Size
This is my code:
.featureIcon {
width: 70px;
float: left;
}
.featureRowSplit {
padding-bottom: 30px;
padding-top: 20px;
}
.featureText {
font-family: 'Lato', sans-serif;
color: #146eff;
margin-left: 80px;
}
<div class="row">
<div class="col-md-8">
<div class="row featureRowSplit">
<div class="col-md-4">
<img src="img/FeatureIcons/1.png" class="featureIcon">
<h3 class="featureText">Cheap</h3>
</div>
<div class="col-md-4">
<img src="img/FeatureIcons/2.png" class="featureIcon">
<h3 class="featureText">Friendly</h3>
</div>
<div class="col-md-4">
<img src="img/FeatureIcons/3.png" class="featureIcon">
<h3 class="featureText">Clean Code</h3>
</div>
</div>
<div class="row">
<div class="col-md-4">
<img src="img/FeatureIcons/4.png" class="featureIcon">
<h3 class="featureText">Quick</h3>
</div>
<div class="col-md-4">
<img src="img/FeatureIcons/5.png" class="featureIcon">
<h3 class="featureText">Helpful</h3>
</div>
<div class="col-md-4">
<img src="img/FeatureIcons/6.png" class="featureIcon">
<h3 class="featureText">Reliable</h3>
</div>
</div>
</div>
<div class="col-md-4">
</div>
</div>
Best Regards,
Ben J
Do want them to align in one column? If so, you can set the whole thing in an unordered list and put the image and header in there. For the css, put list-style-type:none;for the unordered list, and put display:block;and float:left; for the actual li elements.

Height of rows to fill column - Bootstrap layout

I know this may be easy for most of you but I'm stuck with this issue.
I need to implement this design:
Layout Design
... and for now I've got this Current layout.The general structure is a row with col-3 and col-9, this col-9 has two rows, one for name and job title, and the other one for statistics in the page (col-3 for each of them). I need them to fill the height of his parent, but height property doesn't work. Which could be a clean solution? Thanks a lot.
Here is the structure, it's pretty simple tho.
<div class="row profile-header">
<div class="col-md-3 user-image text-center">
<img ...>
<span>..</span>
</div>
<div class="col-md-9">
<div class="row">
<div class="col-md-12">
<h2 class="text-white">...</h2>
<h4 class="text-muted">...</h4>
</div>
</div>
<div class="row text-center">
<div class="col-md-3 stat">
<h3>...</h3>
<small>...</small>
</div>
...
</div>
</div>
Use position: relative on the parent and then position:absolute; bottom: 0; on the children.
Nice explanation there.
Flexbox would be my recommendation although CSS tables might be an option too.
Codepen Demo
Snippet Demo (view Fullscreen)
.user-image {
background: pink;
}
.user-image img {
display: block;
margin: auto;
}
.profile-header {
display: flex;
}
.right {
background: #c0ffee;
display: flex;
flex-direction: column;
}
.stats {
margin-top: auto;
}
.stat {
background: lightgrey;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" />
<div class="row profile-header">
<div class="col-md-3 user-image text-center">
<img src="http://www.fillmurray.com/300/200" alt="" />
<span>User Ranking</span>
</div>
<div class="col-md-9 right">
<div class="row">
<div class="col-md-12">
<h2 class="text-white">User Name</h2>
<h4 class="text-muted">reference</h4>
</div>
</div>
<div class="row text-center stats">
<div class="col-md-3 stat">
<h3>Some Stat</h3>
<small>Some Stat</small>
</div>
<div class="col-md-3 stat">
<h3>Some Stat</h3>
<small>Some Stat</small>
</div>
<div class="col-md-3 stat">
<h3>Some Stat</h3>
<small>Some Stat</small>
</div>
<div class="col-md-3 stat">
<h3>Some Stat</h3>
<small>Some Stat</small>
</div>
</div>
</div>

image vertical align bootstrap with text

I want to know the proper way to put an image in the center of the page, and then beside the image vertical align 2 lines of text. should I put the image and text in one bootstrap coloumn or should i have the image in one coloumn and the text in a seperate coloumn. I know there are a few ways to do this, i just want to know the proper method.
<div class="row">
<div class="col-xs-9">
<img src="https://placeholdit.imgix.net/~text?txtsize=33&txt=350%C3%97150&w=350&h=150" style="vertical-align:middle" />
</div>
<div class="col-xs-3">
<span style="font-size:48px;">Test</span>
<span style="font-size:24px;">Test second line. </span>
</div>
</div>
https://jsfiddle.net/k90s5fec/
This is the right way to do this
div{
display: inline-block;
}
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet"/>
<div class="row">
<div class="col-xs-8">
<img src="https://placeholdit.imgix.net/~text?txtsize=33&txt=350%C3%97150&w=350&h=150" style="vertical-align:middle" />
</div>
<div class="col-xs-4">
<p style="font-size:48px;">Test</p>
<p style="font-size:24px;">Test second line. </p>
</div>
</div>
This is the fiddle
NOTE : Use https:// when importing external resources,
use p tag instead of span if you want to use block texts.
use this
<div class="row">
<div class="col-xs-9">
<img src="https://placeholdit.imgix.net/~text?txtsize=33&txt=350%C3%97150&w=350&h=150" class="displa`enter code here`yed" />
</div>
<div class="col-xs-3">
<span style="font-size:48px;">Test</span>
<span style="vertical-align:middle; line-height: 30px;">Test second line. </span>
</div>
</div>
img.displayed
{
display: block;
margin-left: auto;
margin-right: auto
}
<div class="row">
<div class="col-md-8 col-sm-8 col-xs-8">
<img src="https://placeholdit.imgix.net/~text?txtsize=33&txt=350%C3%97150&w=350&h=150" style="vertical-align:middle" />
</div>
<div class="col-md-4 col-sm-4 col-xs-4">
<div style="font-size:48px;">Test</div>
<div style="font-size:24px;">Test second line. </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>

divs won't horizontally align in CSS

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