Centre Page no matter the resolution viewed?

H

H

Hi all, I've been searching the site for an answer on how to centre my
website no matter what resolution is being used to view the site. I've found
some answers, tried the suggestions but to no avail, I'm a complete beginner
at this.

The site is www.southhyltonclub.co.uk and I'm using FP 2003.

Any help is much appreciated!

Cheers
H.
 
M

Murray

This is not a resolution issue. It's a browser viewport width issue. The
same page will look exactly the same on any resolution screen (although
smaller or larger of course) as long as you keep the browser viewport the
same width in pixels.

Change this -

</head>

to this -

<style type="text/css">
#wrapper { width:760px; margin:0 auto;position:relative; }
/* 760px will display on an 800px screen maximized browser window without */
/* horizontal scrollbars. */
</style>
</head>

change this -

<body ...>
(the ellipsis represents any other attributes that might be mentioned in the
body tag, and SHOULD NOT BE INCLUDED EXPLICITLY!)

to this -

<body ...>
<div id="wrapper">

and this -

</body>

to this -

<!-- /wrapper -->
</div>
</body>

and see if that helps.
 
H

H

Thanks for your help Murray

I think I followed your instruction correctly but I'm a complete beginner so
please bear with me.

I changed the first and third bits and I'm pretty sure I got them in the
correct place, but as for the first 'body' tag. I'm struggling to find it?

I saved and uploaded it but the same problem exists, when I change from
1024x768 to 1152x864 the website sits over to the top left hand side of the
screen leaving a huge border to the right and below...

Confused!
 
M

Murray

Post a link to the page please.

You will not be able to force your page to vertically fill the screen. So
you have to give that one up.
 
M

Murray

Ohboy. It's hard to know where to start with this page. Reading your code
from the top:

1. Your page (and all pages) *must* have a valid and complete doctype.
This tells the browsers how to render the page, and it tells the validators
how to validate the page. If a browser doesn't find a valid and complete
doctype, the page will be rendered in Quirks (or bugwards) mode - and that's
a lousy thing to do to a page that you have spent lots of time working on.

Change this -

<html>

to this -

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>

2. Your page has a misplaced <head> tag. It (and all pages) surely needs
to have this in the proper location.

Change this -

<html>

to this -

<html>
<head> (#4 below will take care of the misplaced one)

3. Your page has this antique and non-functional code on it -

<script language=JavaScript>
<!--

//Disable right mouse click Script
//By Maximus ([email protected]) w/ mods by DynamicDrive
//For full source code, visit http://www.dynamicdrive.com

var message="Function Disabled!";

///////////////////////////////////
function clickIE4(){
if (event.button==2){
alert(message);
return false;
}
}

function clickNS4(e){
if (document.layers||document.getElementById&&!document.all){
if (e.which==2||e.which==3){
alert(message);
return false;
}
}
}

if (document.layers){
document.captureEvents(Event.MOUSEDOWN);
document.onmousedown=clickNS4;
}
else if (document.all&&!document.getElementById){
document.onmousedown=clickIE4;
}

document.oncontextmenu=new Function("alert(message);return false")

// -->
</script>

Please remove it completely from this (and all pages).

4. Your page's misplaced <head> tag *and* a misplaced <body> tag are here -

Change this -

<body ondragstart="return false" onselectstart="return false">
<META HTTP-equiv="imagetoolbar" CONTENT="no">
<head>

to this -

<META HTTP-equiv="imagetoolbar" CONTENT="no">

(deleted the redundant <body> tag, and the redundant <head> tag)

5. Something went awry with your execution of my suggestion. Change this -

</script>
</head>

<div align="center"> to <div id="wrapper">

to this -

</script>
</head>

6. Change this -

<div style="position: absolute; width: 900px;

to this -

<div id="wrapper">
<div style="position: absolute; width: 610px;

7. Skipping all the way down to the bottom of the page, change this -

</body>

to this -

</div>
</body>

Now - add the CSS. Change this -

</head>

to this -

<style type="text/css">
#wrapper { width:610px; margin:0 auto; }
</style>
</head>

That should get you started.
 
H

H

Hey Murray

I'm sure I got everything just where you said this time. It's not made any
difference to how the site displays but it does seem to have messed with my
background... www.southhyltonclub.co.uk

Thanks for you time
H.
 
M

Murray

You have this at the bottom of the page -

</body>


<style type="text/css">
#wrapper { width:610px; margin:0 auto; }
</style>
</head>

That markup was supposed to *REPLACE* '</head>' on the current page.
Instead, you replaced </html> with it. A little bit of HTML knowledge will
keep you out of situations like this....

Please review my earlier post and try again.
 
H

H

Apologies Murray, I have no knowledge of HTML. If I could just get the pages
to sit in the correct place...

OK, i started over and made your suggested code changes, still no change in
the page but hopefully got your code right...?

Appreciate the time you're spent with this!
H.
 
M

Murray

Change this -

<html>


</head>



<META HTTP-equiv="imagetoolbar" CONTENT="no">

to this -

<html>
<head>
<META HTTP-equiv="imagetoolbar" CONTENT="no">

Change this -

#wrapper { width:610px; margin:0 auto; }

to this -

#wrapper { width:900px; margin:0 auto;position:relative; }

(sheepish grin)

And you should be golden. Sorry about the length of the thread.

You may have to reposition the internal layers so that they are placed
properly within this centering container. Once placed, they'll stay there.
 
H

H

Murray, you star! I think I'm there now. Thanks a lot for all of the help and
advice, without it I'd have one wierd looking site.

Apologies for my complete lack of knowledge but you got me there in the end.

Cheers
H.
 
R

Rag

Murray said:
The more you know about HTML, the easier this will be. Good luck!

--
Murray





Murry is this the same principal for Dreamweaver too. I'm having the same issues as H and am still learning the ropes.

Rag
 
R

Ronx

It's the same principle for any web page editor, including Dreamweaver,
Expression Web, FrontPage, Notepad etc.
 
R

Ronx

Murray's code snippet will only centre the page - it will not sort out such
things as declaring three different font sizes for the same text:

..thrColLiqHdr #container #sidebar2 p {
font-size: large;
}
..thrColLiqHdr #container #sidebar2 p {
font-size: 18px;
}
..thrColLiqHdr #container #sidebar2 p {
color: #000;
font-size: 11px;
text-align: left;
}

The above results in black text, left aligned with a size of 11px, and
could be written as

#sidebar2 p {
color: #000;
font-size: 11px;
text-align: left;
}

to give exactly the same effect.
This text will not resize in IE, but will in every other browser - check
the page with FireFox and resize the text
(FireFox 3: View->Zoom->Zoom in with Zoom Text only ticked) and watch
the right sidebar grow as the text size is increased.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top