Jump to content

centering a full page


Yeodan

Recommended Posts

I've been searching for like two hours now and can't figure it out.

 

I just want to center my entire page, using divs, with css. I also want it to work in most browsers.

 

I've found sites that show you how it's done, but there's no explanation and it's too complicated to just copy it.

I've also found sites that show it, but when I try it it just doesn't work.

 

 

here's my css if that helps:

I've been trying to get it to work so there might be some strange things in it.

body {
background-color: #F5FFF5;
color: #000000;
    text-align: center;
}
TD {
FONT-FAMILY: Verdana, Arial;
FONT-SIZE: 9pt;
color: #000000;
}
A {
COLOR: #0000FF; TEXT-DECORATION: none;
}
A:hover {
COLOR: #6969FF; TEXT-DECORATION: none;
}
.input {
BACKGROUND-COLOR: #006600;
COLOR: #CCFFCC;
border-style: solid;
border-color: #66FF00;
FONT-FAMILY: Verdana, Arial;
FONT-SIZE: 9pt;
TEXT-DECORATION: none;
}


container {
    margin: 0 auto;
text-align: left;
}

#banner {
    left: 25px;
    top: 10px;
position: absolute;
}

#avatar {
left: 15px;
    top: 100px;
position: absolute;
}

#link {
    left: 25px;
    top: 375px;
position: absolute;
}

#news {
left: 200px;
    top: 100px;
    height: 171px;
    width: 370px;
    position: absolute;
    background-image: url("../images/testbg.png");
}

#update {
left: 588px;
    top: 100px;
    height: 171px;
    width: 100px;
    position: absolute;
    background-image: url("../images/testbg.png");
}

#main {
left: 200px;
    top: 365px;
    height: 50px;
    width: 100px;
position: absolute;
}

Link to comment
https://forums.phpfreaks.com/topic/155711-centering-a-full-page/
Share on other sites

Actually, you could center the page. I don't recommend using this technique. As absolute positioning is incorrect to center things!

 

Enclose all your contents within a div called - "html-center"

 

<body>

<div id="html-center">

      .......... all your body contents

</div>

</body>

 

In your css:

 

#html-center {

  width: (-specify width-)px; /* like - width: 800px; */

  margin: 0 auto;

  position: relative;

}

 

There you go! It'll center;

Actually, you could center the page. I don't recommend using this technique. As absolute positioning is incorrect to center things!

 

Enclose all your contents within a div called - "html-center"

 

<body>

<div id="html-center">

      .......... all your body contents

</div>

</body>

 

In your css:

 

#html-center {

  width: (-specify width-)px; /* like - width: 800px; */

  margin: 0 auto;

  position: relative;

}

 

There you go! It'll center;

That will only center it for Firefox, Opera, etc. but not IE

 

to center in IE just add

text-align:center;

to body then in the #html-center reset it with

text-align:left;

Actually, you could center the page. I don't recommend using this technique. As absolute positioning is incorrect to center things!

 

Enclose all your contents within a div called - "html-center"

 

<body>

<div id="html-center">

      .......... all your body contents

</div>

</body>

 

In your css:

 

#html-center {

   width: (-specify width-)px; /* like - width: 800px; */

   margin: 0 auto;

   position: relative;

}

 

There you go! It'll center;

That will only center it for Firefox, Opera, etc. but not IE

 

to center in IE just add

text-align:center;

to body then in the #html-center reset it with

text-align:left;

You are wrong. It will work fine in IE if you set a valid DOCTYPE.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.