Jump to content

Recommended Posts

Posted (edited)

Hey guys, as always I’m trying to do something seemingly simple and am having some bizarre issues ☺ I’m just trying to make a simple image grid without using tables.

 

sheffieldfurniture.com/imagegrid/furniture.html

First issue is, why is there a space between the images here? (in most browsers) It seems like it’s adding a margin although Chrome developer tools is not saying that the images have any margin applied to them. I do want to have the images spaced out but I can’t do the math necessary for doing that if some browsers are going to be randomly adding a margin.

 

 

sheffieldfurniture.com/imagegrid/furniturefloat.html

I was able to fix this by floating everything left. Is this the proper fix? It still bugs me that I couldn’t figure out why the images had space in-between

 

 

Let me know if I’m going about this wrong, is this how you guys would do a simple images grid? Also, I suck at math, how would you go about determining how large to make the images and how much margin? The parent container will be 960 Pixels and I’d like rows of 5 across to be centered

Edited by jpf566
Posted (edited)

Edit this code in the head section style tag:-

#content img {
margin:0px; display: block; float: left;
}

 

The img element is normally an inline element and margin won't process on an inline element so make it a block element.

 

It may only solve part of your problems, but it's a start.

 

Your actual image size is 188*188px not 180*180px so edit all the markup sizes to delete the 180px sizes (you don't need sizes unless you want to resize the image)

<img src="images/bed.jpg" />

<img src="images/bed.jpg" />


<img src="images/bed.jpg" />


<img src="images/bed.jpg" />


<img src="images/bed.jpg" />

<img src="images/bed.jpg" />

and edit the #content style width to 5 * 188px = 940px; and the margin: auto will center it.

#content {

width: 940px; /*916px;*/
padding:0px;
background:#D9D9D9;
margin-left:auto;
margin-right:auto;
margin-top:  50px;
}


Edited by Wickham

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...