...

View Full Version : Aligning the body...



mccdaddy
02-16-2009, 08:31 PM
I have a feeling this is going to sound like a stupid question but I won't let that stop me from asking it:

The body of my website, which I created from a template, is set to the left of the screen. I want to move it to center. Looking at the coding it seems that I would have to change each DIV's left alignment, which looks like a daunting task. I'm wondering if there is a simpler way to shift the body to center.

Thanks.

http://thefactotum.home.comcast.net/~thefactotum/index.html (http://thefactotum.home.comcast.net/~thefactotum/index.html)

mccd

Excavator
02-16-2009, 10:00 PM
Hello mccdaddy,
No such thing as a stupid question - how else are we supposed to figure these things out?

Make these changes to your html -

<div id="container">
<a name="top"></a>
<div id="top">
<div id="logo"><img src="imgs/fact_logo.jpg" alt="FACTotum Logo" width="220" border="0" height="83"></div>
</div>
<!-- *be sure to add your url in (herf = " URL_HERE ")* -->
<div id="lnk1"><a href="index.html" class="navlnks">Hom
/...snip
/
/
/
snip.../
r="0"></a><br><a target="_new" href="http://counter37.bravenet.com/index.php?id=367396&amp;type=overview&amp;usernum=3161311238"><img src="http://assets.bravenet.com/common/images/counter/tags/1_stat.gif" target="_blank" alt="View Statistics" border="0"></a></td></tr></tbody></table>
<!-- End Bravenet.com Service Code -->

</div>
<!--end container--></div>


And then add this to your CSS:
#container {
width: 691px;
margin: 0 auto;
}
div#top {
positio

mccdaddy
02-17-2009, 05:19 AM
Hi Excavator,

Thanks for your reply. I added the coding you recommended but the body is still left aligned. Did I do something wrong?

http://thefactotum.home.comcast.net/~thefactotum/index.html

mccd

Majoracle
02-17-2009, 05:28 AM
It's not working because you've absolute positioned everything where it needs to be. If you want to center it, you're going to have to abandon that method, which is probably going to set you back a ways.

Excavator
02-17-2009, 07:41 AM
Yeah, your absolute positioning is really not helping.
Have a look at http://www.tyssendesign.com.au/articles/css/absolute-positioning-pitfalls/ before you do the re-write

mccdaddy
02-18-2009, 03:26 AM
Excavator, I read the article on the pitfalls of absolute positioning. It was informative, thanks.

The article didn't address an alternative. How did I undo the positioning? Do I just delete every "position: absolute;" reference?

mccd

Excavator
02-18-2009, 04:29 AM
Well, deleting all your absolute positioning will just remove all the positioning. You need to have some sort of control over the layout.

That's why I mentioned the re-write. If you remove the ap, it's the same as starting over.

Floats and margins are used instead of ap.
Are you going to do this yourself?

mccdaddy
02-18-2009, 04:55 AM
My coding knowledge isn't what I'd like it to be but, yes, I'm going to try it. I found an instructive tutorial- http://blog.codebeach.com/2007/03/absolute-and-relative-position-in-css.html- which gave me a better understanding of relative vs absolute positioning.

I'll be back with an SOS if the need arises.

Thanks again.

mccd

Excavator
02-18-2009, 05:16 AM
I just looked further into your code. Some very strange stuff going on there. Your background image is 1400px wide, your body is set to 800px wide...

Excavator
02-18-2009, 05:20 AM
Here's a good start for you:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
html, body {
font: 12px Arial, Helvetica, sans-serif;
background: #ECEADD;
text-align: center;
}
* {
margin: 0;
padding: 0;
border: none;
}
#container {
width: 691px;
margin: 0 auto;
overflow: auto;
text-align: left;
}
</style>
</head>
<body>
<div id="container">
<!--end container--></div>
</body>
</html>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum