SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Evangelist kuhajeya's Avatar
    Join Date
    Sep 2003
    Posts
    486
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    problems in centering the content in IE

    hi guys,

    i have got a problem in IE when i want to center the content

    here, I have div -> #content which will contain all other contents (divs) inside it

    Code:
    body{	
    	width:782px;
    	margin: 50px auto;
    	background-color:#808080;
    	text-align:center
    }
    
    #content{ /*This is the main content*/	
    	position:relative;
    	margin:0;
    	padding:0;
    	border: 1px solid #2A0055;
    	background: #fff;
    	
    }
    it is perfrect in FF but fill the entire width in IE, can somone tell me whats going wrong here?

    thanks

  2. #2
    Winemaster bronze trophy BonRouge's Avatar
    Join Date
    Oct 2004
    Location
    Sendai, Japan
    Posts
    2,417
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Give the content a width rather than the body.

  3. #3
    SitePoint Addict eJM's Avatar
    Join Date
    Feb 2004
    Location
    teh Ether
    Posts
    221
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    BonRouge, is that because positioning, whether relative or absolute, requires a width?

    Also, since the BODY element shouldn't have a width, should it also not have a margin except maybe 0;?

    Thanks for any clarification.

    Grump

  4. #4
    Winemaster bronze trophy BonRouge's Avatar
    Join Date
    Oct 2004
    Location
    Sendai, Japan
    Posts
    2,417
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Grump,
    I'm glad you came along, because you've made me realise that my answer wasn't very good.
    The CSS up there should actually work OK - I've just tested it. What I now think must be the problem is that kuhajeya either doesn't have a complete DTD, or (s)he's using an older version of IE.
    The answer in the first case would be to get one and in the second case to use 'text-align:center;' on the body and a width on the content (if I remember right).
    I guess I gave my first reply so quickly because it just looked strange to give the body instead of the inner wrapper.
    Quote Originally Posted by GrumpyJim
    Is that because positioning, whether relative or absolute, requires a width?
    No. You can position things without a width.

    Also, since the BODY element shouldn't have a width, should it also not have a margin except maybe 0;?
    I didn't say the body shouldn't have a width - I sometimes give the body a minimum width to stop the layout falling to bits. You can also give the body a margin - no problem there - but I'd usually give the body '0' margins.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •