Centering my website

  • chargrims
  • Beginner
  • Beginner
  • chargrims
  • Posts: 53

Post 3+ Months Ago

Ok guys, basically what I am wanting to do, is set an HTML page alignment to 'center' so that all the content appears in the middle, regardless of the user's screen resolution. I've been web-designing for three years, but I can't seem to work out how! :roll:
  • SSH-Raj
  • Expert
  • Expert
  • User avatar
  • Posts: 588

Post 3+ Months Ago

put in side of this :
Code: [ Select ]
<center> </center>

there's lots of other ways to do the same thing.
  • chargrims
  • Beginner
  • Beginner
  • chargrims
  • Posts: 53

Post 3+ Months Ago

How do you mean? I didn't see any code there :?
  • chargrims
  • Beginner
  • Beginner
  • chargrims
  • Posts: 53

Post 3+ Months Ago

Ignore that, it's shown itself this time
  • chargrims
  • Beginner
  • Beginner
  • chargrims
  • Posts: 53

Post 3+ Months Ago

Yeh thanks that worked fine, I knew it would be something simple, just couldn't find it in dreamweaver!
  • rjstephens
  • Professor
  • Professor
  • User avatar
  • Posts: 774
  • Loc: Brisbane, Australia

Post 3+ Months Ago

That method works but this ones better

where you have <center>, put <div align="center">

and where you have </center>, put </div>


//which ever mod it was that fixed that for me, thanks. But I think it looks better like this
  • rtm223
  • Mastermind
  • Mastermind
  • User avatar
  • Posts: 1855
  • Loc: Uk

Post 3+ Months Ago

Code: [ Select ]
.centered{
  margin:auto;
}
  1. .centered{
  2.   margin:auto;
  3. }


to get it working on IE/mac
Code: [ Select ]
.centered{
  margin-left:auto;
  margin-right:auto;
}
  1. .centered{
  2.   margin-left:auto;
  3.   margin-right:auto;
  4. }



To get it working in IE5/win AND IE/mac:
Code: [ Select ]
body{
  text-align center;  /*IE 5x bug*/
}
.centered{
  margin-left:auto;
  margin-right:auto;
  text-align:left;  /*counter the effect of bug above*/
}
  1. body{
  2.   text-align center;  /*IE 5x bug*/
  3. }
  4. .centered{
  5.   margin-left:auto;
  6.   margin-right:auto;
  7.   text-align:left;  /*counter the effect of bug above*/
  8. }
  • b_heyer
  • Web Master
  • Web Master
  • User avatar
  • Posts: 4581
  • Loc: Maryland

Post 3+ Months Ago

What rtm223 posted is also integral for mozilla/IE as well.
  • cjxxi
  • Expert
  • Expert
  • cjxxi
  • Posts: 566
  • Loc: Fort Worth, TX

Post 3+ Months Ago

here is the script..



<BODY>
<SCRIPT LANGUAGE="JavaScript">
<!--
var ns4up = (document.layers) ? 1 : 0;
var ie4up = (document.all) ? 1 : 0;

function HOffset()
{
var window_width = window.innerWidth ? window.innerWidth : (document.body.clientWidth ? document.body.clientWidth : 0);
return Math.max( 0, Math.floor( (window_width - 0) / 2 ) - 0 ).toString();
}
document.write( "<DIV ID='IDAlignPage' style='position:absolute;top:0px;left:" + HOffset() + "px;'>&nbsp;" );
function DoReposition()
{
var o='IDAlignPage';
if(document.getElementById(o)){
var e=document.getElementById(o);
e.style.left=HOffset()+'px';
}else if(ie4up){
var e=eval('document.all.'+o);
e.style.left=HOffset()+'px';
}else if (ns4up){
var e=eval('document.'+o);
e.left=HOffset();}
}

window.onresize=DoReposition;
window.onload=DoReposition;
//-->
</SCRIPT>






this is the first thing to go in the document body...

that's it!



hope it hepls :wink:
  • Abelius
  • Proficient
  • Proficient
  • User avatar
  • Posts: 260
  • Loc: Miami Beach, FL, USA

Post 3+ Months Ago

Oh mine!

So much fuss for a center shot...??? LOL :)

I think it's would be easier to find the center of Tibet (by mule) than some of the ideas given in here...
  • cjxxi
  • Expert
  • Expert
  • cjxxi
  • Posts: 566
  • Loc: Fort Worth, TX

Post 3+ Months Ago

:multi:


It may be a-llittle long or I better say too long...

But, it works better than the others .. :wink: Is better isn't it!



It controls all the document, thogh! :!:
  • Mas Sehguh
  • Mastermind
  • Mastermind
  • User avatar
  • Posts: 1852

Post 3+ Months Ago

I am curious: Why is <div align="center"> better than <center>? They are synonyms. This would be an interesting browser bug.
  • Mr Smith
  • Graduate
  • Graduate
  • Mr Smith
  • Posts: 150
  • Loc: Birmingham, England

Post 3+ Months Ago

Sam Hughes wrote:
I am curious: Why is <div align="center"> better than <center>? They are synonyms. This would be an interesting browser bug.


more to the point: they're both deprecated.....
  • TheArchitect
  • Professor
  • Professor
  • TheArchitect
  • Posts: 764
  • Loc: Australia

Post 3+ Months Ago

Was looking for something like this.
  • TheArchitect
  • Professor
  • Professor
  • TheArchitect
  • Posts: 764
  • Loc: Australia

Post 3+ Months Ago

Was looking for something like this.

Post Information

  • Total Posts in this topic: 15 posts
  • Users browsing this forum: No registered users and 14 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.