Forum Moderators: not2easy

Message Too Old, No Replies

How do I position 4 or 5 jpegs in a row?

         

Digmen1

11:31 pm on May 9, 2007 (gmt 0)

10+ Year Member Top Contributors Of The Month



Hi Guys

I am new to XTML and CSS and am starting my first website.

I wish to display 4 or 5 jpegs on a row, and want to know the best way to space them out nicely.

Any suggestions would be much appreciated

Regards

Digby
NZ

limbo

9:07 am on May 10, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi Digby

Welcome to WebmasterWorld [webmasterworld.com] :)

Using CSS and HTML to do this is quite straight forward.

Firstly you'll need to place your images within a named container in your html - A <div> is typical.

Then use CSS to position and pad the images.

So it may look like:

html:

<div id="gallery">
<img src="1.jpg"><img src="2.jpg"><img src="3.jpg"><img src="4.jpg">
</div>

CSS
#gallery img {padding;0 10px 0 0;}

The above code snippet - in the HTML I named the container gallery. The CSS selects the gallery and says all images within it have padding to their right of 10 pixels.

:)

Digmen1

11:34 am on May 11, 2007 (gmt 0)

10+ Year Member Top Contributors Of The Month



Thanks for that Limbo!

That worked great!

Now all I need to know is

1 How to align the whole gallery say 150 pixels in from the left margin.

(I have tried margin-left, but that moves each img over.

Kind Regards'

digby

limbo

1:09 pm on May 11, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Heh Digby.

To do that you could add a margin to the container itself:

CSS

#gallery {margin:0 0 0 150px;}

Note the CSS short hand - CSS properties follow the compass top(0), right(0), bottom(0), left(150px).

More reading - lots of good stuff in here: [webmasterworld.com...]

Digmen1

11:02 am on May 13, 2007 (gmt 0)

10+ Year Member Top Contributors Of The Month



Thanks Limbo

That worked great.

The compass info was handy, and those links look very useful, it will take me a while to check all those out!

Kind Regards

Digby
NZ