Image postioning and text

Associate
Joined
14 Jan 2008
Posts
301
HI. I'm trying to position an image 800 pixels down the screen with some text directly underneath it. No prob positioning the image using 'margin:800px', however this causes the text to appear 800 pixels underneath the image. :confused:

Am new to this so any help gratefully appreciated.
 
Apply the CSS to a div instead containing both the image and the text?

Code:
.stuff {
top:800px;
}

<div class="stuff">
<img src="img.jpg"><br>This is stuff
</div>

Not tested, and of course this'll need to be centered.
 
Last edited:
That would be the CSS class .stuff.

Any tag with the class "stuff" will have that style applied to it. You can obviously name it anything you want.
 
HI. I'm trying to position an image 800 pixels down the screen with some text directly underneath it. No prob positioning the image using 'margin:800px', however this causes the text to appear 800 pixels underneath the image. :confused:

Am new to this so any help gratefully appreciated.

Add margin-bottom:0; to that.

As margin works like this:

margin: top right bottom left;

So margin:800px you are actually telling it to have 800px all the way around the image.
 
Add margin-bottom:0; to that.

As margin works like this:

margin: top right bottom left;

So margin:800px you are actually telling it to have 800px all the way around the image.

That works :cool: Thanks.

Now have 4 images in a line 800 pixels down. Got to figure out how to centre them on the page now.
 
Now have 4 images in a line 800 pixels down. Got to figure out how to centre them on the page now.

Just out of interest why are they 800px down the page?

To centre them in horizontal Im another who likes to use margin auto, so yours would be margin:800px auto 0;

You need a doctype on your page for this to work in IE (I use strict, but its up to you I guess).
 
For centering every site I build the best way I find is to use a container div and place everything inside

#container {
margin:0 auto;
padding:0;
width:800px;
}

That almost works except it centers my images vertically when i need them in a line horizontally. Here's the code:

div.img
#container {
margin:800px auto 0;
margin-bottom:0;
margin-left: 0;
margin-right: 0;
border:1px solid #0000ff;
height:240;
width:157;
float: left;
text-align:center;
}
div.img img
{
display:inline;
margin:0px;
margin-bottom:0;
margin-left: 0;
margin-right: 0;
border:1px solid #ffffff;
}
div.img a:hover img
{
border:1px solid #0000ff;
}
div.desc
{
text-align:center;
font-weight:normal;
width:120px;
margin:2px;
}
 
Just out of interest why are they 800px down the page?

To centre them in horizontal Im another who likes to use margin auto, so yours would be margin:800px auto 0;

You need a doctype on your page for this to work in IE (I use strict, but its up to you I guess).

I have a background image and a space for other images to start 800 pixels down.

doctype? This is all totally new to me. If I had money I'd pay someone to do it as it doesn't come naturally.

Thanks for all help and suggestions so far.
 
Back
Top Bottom