Page 1 of 1

Center browser upon viewing page

Posted: Mon Nov 02, 2009 4:57 pm
by Jafil21
Hello everyone,

I'm looking for a way to implement the following requirement: Upon viewing a web page, which will host a very large background image (1900 by 1200 pixels wide), I want the visitor to be centered in the page. Which means, I want my webpage content to be placed at the center of the page in an imaginary (or, perhaps, not so imaginary) box and the browser's scrollbars to be adjusted relevantly.

Any way that I can achieve this?

Thank you.

Re: Center browser upon viewing page

Posted: Tue Nov 03, 2009 9:51 am
by akuji36
Css can handle this for you. Create a class

for your image : decide on height and width and

centering:
in html

Code: Select all

 <html>
<head>
<style>
centerme {
   height:1900
   width:1700 
    margin-left: auto;
    margin-right: auto;
 
}
</style>
</head>
<body>
<img src="sunset.gif" class="centerme">
 
</body>
</html>
 
It may be easier if you set up a div and place pic inside div.
Then style div and style pic.

Take a look here:

http://www.w3.org/Style/Examples/007/center

thanks

Rod