How do i... :D

Soldato
Joined
26 Feb 2007
Posts
14,177
Location
Leafy Cheshire
Sorry, this is retardedly simple im sure, but "how to" sites dont seem to have my answer...

I've made a graphic (psd/jpg/whatever) to put on my index page as a page holder... what i want is that graphic to sit in the centre of the page, no matter what size the window is (ie, on different monitors). There's nothing else on teh page, it's just blank, and i just one that one graphic in the centre :)

What's the HTML code i need?

Cheers
 
Code:
<img id="image" src="http://blah/image.jpg" height="200" width="300" />
Code:
img#image {
  position: absolute;
  left: 50%;
  top: 50%;
  margin-left: -150px;
  margin-top: -100px;
}
 
Cheers guys. I looked into both, and then kinda stumbled onto a table form like

Code:
<HTML>
<BODY>
<table width="100%" height="100%" valign="middle">
<tr>
<td>
<center>
<img id="image" src="image.png" height="480" width="640" />
</center>
</td>
</tr>
</table>
</BODY>
</HTML>

Cheers :D
www.rhyscartwright.co.uk

I know it's poor, but it's not for long... the site will be finished in a week or so :)
 
Dj_Jestar has the model solution here, the other two are just horrific. It's not a big deal here, just don't get into bad habits when you start to build the actual site.
 
I know 0 about HTML/CSS or any type of web design, and I couldn't get Jestar's to do anything other than display that code as text. Luckily, the site isn't being done by me, and is being done professionally at considerable cost ;)
 
as in
Code:
<img id="image" src="http://www.rhyscartwright.co.uk/Indexplaceholder.png" height="480" width="640" />
<style type="text/css">
img#image {
  position: absolute;
  left: 50%;
  top: 50%;
  margin-left: -150px;
  margin-top: -100px;
}
</style>

?
because that doesn't sit in teh centre for me, it's way off to the right and too far down, and poduces scroll bars.
 
This is what you want, you need to adjust the negative margins so they are half of the size of your image:

Code:
<img id="image" src="http://www.rhyscartwright.co.uk/Indexplaceholder.png" height="480" width="640" />
<style type="text/css">
img#image {
  position: absolute;
  left: 50%;
  top: 50%;
  margin-left: -320px;
  margin-top: -240px;
}
</style>
 
Cheers.

Clearly my idiocy is far beyond what any of you could have imagined ;) It's ok to tell me so publically.

Works great, ta. Site is clickable in sig. It's only temp, but i'll keep that for future reference.

Cheers again.
 
Last edited:
Back
Top Bottom