Forum Moderators: open

Message Too Old, No Replies

Simple question?

centred page

         

jsnow

5:32 pm on Nov 21, 2003 (gmt 0)

10+ Year Member



Probably a very simple thing to do! I want my pages to centre when they load in a browser but not sure how to do it?

Also I may as well ask this here too. How do you change the colours of the scroll bar? I use dreamweaver to edit CSS and other code

Thanks in advance!

AWildman

5:34 pm on Nov 21, 2003 (gmt 0)

10+ Year Member



If you're not doing anything special to the background, you can use a div with no padding or margins set to 100% width and align it center. Then, you can nest stuff inside that div and it will be centered.

tedster

10:49 pm on Nov 21, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



AWildman's approach definitely will work in current browsers -- unfortunately the
align
attribute is now deprecated, so the code is not future-proof and will not validate.

Here's one approach:

div {
margin:0 auto;
}

Drawback: IE5 doesn't support properly

Here's another, assuming a 700 px width div:

div {
width:700px;
position: absolute;
left:50%;
top:0;
margin-left:-350px;
}

That last one is pretty clever -- absolute position in the exact center, but then negative left margin to move the div back to the left by half its width. You get half on each side of the center line.
Drawback: NN4 does not handle it correctly.

Poke around in our CSS forum -- lots of posts about this. Here's one thread on the topic:
[webmasterworld.com...]

hartlandcat

1:16 pm on Nov 22, 2003 (gmt 0)

10+ Year Member



Coloured scrollbars will work only in IE 5.5+, Konqueror 3.0+ and if enabled manually, Opera 7.0+. They are not recommended for use, and are an indication of an amature web designer.

MatthewHSE

4:28 pm on Nov 22, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



They are not recommended for use, and are an indication of an amature web designer.

Or one who knows his audience will appreciate such things! :)

Seriously, there are legitimate uses for colored scrollbars. For instance, though I won't use them for the main scrollbars, I have no qualms about coloring the scrollbars on a scrolling div.

hartlandcat

11:27 pm on Nov 22, 2003 (gmt 0)

10+ Year Member



Recent studies show that most users feel more comfortable with the standard scrollbar. Most people aren't tech-savvy, and will become confused if scrollbars don't appear as expected.

Do any of the major sites use coloured scrollbars? MSN? Yahoo? Lycos? Amazon? Ebay? Netscape? Google? No, they don't.

dcrombie

1:55 pm on Nov 23, 2003 (gmt 0)



You should be able to centre your page using CSS on the BODY tag:

BODY {
width: 700px;
align: center;
}
(not tested)

BjarneDM

4:11 pm on Nov 23, 2003 (gmt 0)

10+ Year Member



the two most used tricks to center content horizontally are described in all their glorious detail here: [bluerobot.com...]

Now, if you are using fully standards compliant xhtml inclusive of serving the correct Content-Type of application/xhtml+xml, the <html> tag is the outermost tag of the page and has taken the role of the <body> tag in traditional html. Thus, in xhmtl <body> is just another <div> and can be styled appropriately. I'm doing this on one of my own sites: [mozilla.mathiesen.info...] . And you had better visit it with a browser capable of handling 'Content-Type: application/xhtml+xml' or you'll just get a 'sorry'-page. The css can be accessed directly through this url: [mozilla.mathiesen.info...]

shasan

6:54 pm on Nov 23, 2003 (gmt 0)

10+ Year Member




You should be able to centre your page using CSS on the BODY tag:
BODY {
width: 700px;
align: center;
}
(not tested)

I don't know why, but there's no such thing as an align property in CSS2. It may work in IE6 though (*shrug*). I've used the 'text-align: center' property with success before. text-align will center all contents of the box.

lizzie

7:11 pm on Nov 23, 2003 (gmt 0)

10+ Year Member


As an amateur who has been making webpages for 4 years I use Dreamweaver to do the centering for me.
I set it for centered in "page properties" or some such thing( I'm too lazy to look it up right now.)
I don't understand div and such but with Dreamweaver it will center the page automatically if you tell it to.
Is this wrong?

jsnow

7:18 pm on Nov 23, 2003 (gmt 0)

10+ Year Member



I did it using body tag in CSS and centre, not sure if it works on every browser but it's not the end of the world if it doesn't!

Thanks for all your help