Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Aug 2011
    Location
    England
    Posts
    23
    Thanks
    9
    Thanked 0 Times in 0 Posts

    css div container help!

    Hi there. I'm quite new to css, and I've been looking all over google to center my content in a page, very much like www.skittles.com. I wasnt able to find out how to do it, does anyone know how to do this Also, I wouldnt mind knowing how to put a background image behind the container aswell, like the sky affect on the skittles website. Thank you very much for any help provided!.
    Last edited by camzenxbt; 08-13-2011 at 09:58 PM. Reason: I forgot to add required information.

  • #2
    Registered User
    Join Date
    Jun 2011
    Posts
    1,063
    Thanks
    12
    Thanked 241 Times in 240 Posts
    margin: 0 auto; will set an "auto" margin on each side of the "container". This auto will be the same size on each side, and is calculated based on the width of the container (so you need to define a width for margin: 0 auto; to work.

    Code:
    .container {
     width: 1000px;
     margin: 0 auto;
    }
    Code:
    <div class="container">
     <!-- Header, Content, Footer -->
    </div>

    ----

    that sky background is done in photoshop. to place it in the background, they probably set it to the body

    Code:
    body {
     background: url('/ .png') 0 0 no-repeat;
    }
    Code:
    <body>
     <div class="container"></div>
    </body>
    Last edited by Sammy12; 08-13-2011 at 10:06 PM.

  • #3
    New Coder
    Join Date
    Aug 2011
    Location
    England
    Posts
    23
    Thanks
    9
    Thanked 0 Times in 0 Posts
    Thank you very much for your help!.


  •  

    Tags for this Thread

    Posting Permissions

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