SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: Centre trouble

  1. #1
    SitePoint Zealot
    Join Date
    May 2004
    Location
    uk
    Posts
    151
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Centre trouble

    According to this page http://www.maxdesign.com.au/presentation/center/ the following code should centre the background image but it doesn’t.
    Code:
    body
    {
    text-align: center;
    }
    
    
    #pic
    {
    margin-top:10px;
    margin-right:auto;
    margin-left:auto;
    background-image: url(images/Bouncy_Castle.jpg);
    background-repeat: no-repeat;
    background-attachment:fixed;
    height:600px;
    }
    Code:
    <body>
    
    <div id="pic">
    </div>
    
    </body>
    Anyone know why?

    Cheers,

    doo

  2. #2
    Non-Member Egor's Avatar
    Join Date
    Jan 2004
    Location
    Melbourne, Australia
    Posts
    7,305
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by doolally
    Anyone know why?

    Cheers,

    doo
    Yup, to center using margin auto you need to specify a width.

    A div by default is 100% wide and is a block element.

  3. #3
    SitePoint Zealot
    Join Date
    May 2004
    Location
    uk
    Posts
    151
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks Lots!


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
  •