Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Page 1 of 2 1 2 LastLast
Results 1 to 10 of 12
  1. #1
    Senior Member Holokai's Avatar
    Join Date
    Sep 2004
    Location
    Honolulu, HI
    Posts
    127
    Member #
    7707
    How does one center a div, without using tables? I'm totally lost here. Thanks for any help.
    -----------------------------------------------
    I know just enough to be dangerous to myself and others around me... I'm more of a CSS kamikaze than a CSS ninja...

  2.  

  3. #2
    Senior Member Trico's Avatar
    Join Date
    Feb 2004
    Location
    Nottingham, UK
    Posts
    894
    Member #
    5081
    Code:
    ...<head>
    <style type="text/css" media="screen">
    html, body {
    
    text-align: center;
    
    }
    
    #centre {
    
    width: 760px;
    text-align: left;
    margin: 0 auto;
    
    }
    </style>
    </head>...
    Code:
    <div id="centre">This block element will be centred in the browser window.</div>

  4. #3
    Junior Member kokushta's Avatar
    Join Date
    Sep 2004
    Posts
    14
    Member #
    7703
    The <DIV> tag is like <P> tag. Just set the attribute ALIGN="center" and you're on.
    Code:
    <div align="center">this text stands in the middle.</div>

  5. #4
    Member Juvenall's Avatar
    Join Date
    Sep 2004
    Location
    #!/usr/bin/Detroit
    Posts
    67
    Member #
    7716
    However, that's not W3C valid..
    Juvenall Wilson_______[juvenall@gmail.com]_________________
    Forum Directory - ForumFox.com
    YaBB Project Admin/Former allmusic.com designer

  6. #5
    Senior Member Holokai's Avatar
    Join Date
    Sep 2004
    Location
    Honolulu, HI
    Posts
    127
    Member #
    7707
    Ok, I've tried all of those things, but I didn't use the margin: 0 auto; line. That shouldn't affect the centering should it?
    Code:
    body{
    text-align: center;
    	background-color: #2C4762;
    	font-family: verdana, arial;
    	font-size: .8em;
    	}
    .main{
    	width: 900px;
    	height: 100%;
    	border-width: 1px;
    	border-color: #546A80;
    	border-style: solid;
    	background-image: url(../images/sky.jpg);
    	background-repeat: no-repeat;
    	backroud-color: #2C4762; 	}
    -----------------------------------------------
    I know just enough to be dangerous to myself and others around me... I'm more of a CSS kamikaze than a CSS ninja...

  7. #6
    Member Juvenall's Avatar
    Join Date
    Sep 2004
    Location
    #!/usr/bin/Detroit
    Posts
    67
    Member #
    7716
    Depending on the code, it could. More so in other resolutions. Give it a shot at something better or smaller then what you're running right now.
    Juvenall Wilson_______[juvenall@gmail.com]_________________
    Forum Directory - ForumFox.com
    YaBB Project Admin/Former allmusic.com designer

  8. #7
    Senior Member Trico's Avatar
    Join Date
    Feb 2004
    Location
    Nottingham, UK
    Posts
    894
    Member #
    5081
    Yes it does, margin: 0 auto; basicly means...
    Code:
    margin-top: 0;
    margin-bottom: 0;
    margin-left: auto; 
    margin-right: auto;
    Using auto allows the browser to soak up the excess space either side pushing your main layout table/div into the centre of the page.

    The text-align: center; is for browsers that interpret the CSS wrong/differently.

  9. #8
    Senior Member Holokai's Avatar
    Join Date
    Sep 2004
    Location
    Honolulu, HI
    Posts
    127
    Member #
    7707
    Gentlemen, I thank you much. If you're ever in Hawaii, I'll buy some Cigars.
    -----------------------------------------------
    I know just enough to be dangerous to myself and others around me... I'm more of a CSS kamikaze than a CSS ninja...

  10. #9
    Member Juvenall's Avatar
    Join Date
    Sep 2004
    Location
    #!/usr/bin/Detroit
    Posts
    67
    Member #
    7716
    /me changes his vacation plans *grins*
    Juvenall Wilson_______[juvenall@gmail.com]_________________
    Forum Directory - ForumFox.com
    YaBB Project Admin/Former allmusic.com designer

  11. #10
    Senior Member Holokai's Avatar
    Join Date
    Sep 2004
    Location
    Honolulu, HI
    Posts
    127
    Member #
    7707
    haha. I bet. A good cigar is a great incentive I know someone who has cubans!!! :rambo:
    -----------------------------------------------
    I know just enough to be dangerous to myself and others around me... I'm more of a CSS kamikaze than a CSS ninja...


Page 1 of 2 1 2 LastLast

Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 06:55 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com