CSS help - Div posistioning...

Discussion in 'Software' started by Akumos, Nov 12, 2008.

  1. Akumos

    Akumos Private E-2

    Hi all

    I've always centered a div in CSS by using:

    #container {
    width: 80%;
    border: 4px solid black;;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
    }

    But now I've started using dreamweaver and this is not happening. Any ideas?

    I'm trying to use a grey backgound (#cccccc) and a div (or container) with a white background for the conent spreading 80% accross the page.
     
  2. Akumos

    Akumos Private E-2

    Got it now Thanks!!

    Position=Fixed!!!
     
  3. w3d

    w3d Private E-2

    I'm not sure that position:fixed; is necessarily your answer?! Using position:fixed; (which incidentally isn't supported by IE6) your container is positioned according to the 'absolute' model and taken out of the flow of the page... which does not normally lend itself to being centered by setting the left and right margins to auto.

    However, the 2 semi-colons at the end of this line:
    are likely to cause rendering issues with your CSS.
     
  4. Akumos

    Akumos Private E-2

    Thanks for that w3d, you was right in saying that it didn't centre my page. Still working on it.
     
  5. PC-XT

    PC-XT Master Sergeant

    Would it work to set margin-left:10%; or does it not support percentages in the same way?
     
  6. Akumos

    Akumos Private E-2

    Spot on Pc-XT. Thank you!!
     

MajorGeeks.Com Menu

Downloads All In One Tweaks \ Android \ Anti-Malware \ Anti-Virus \ Appearance \ Backup \ Browsers \ CD\DVD\Blu-Ray \ Covert Ops \ Drive Utilities \ Drivers \ Graphics \ Internet Tools \ Multimedia \ Networking \ Office Tools \ PC Games \ System Tools \ Mac/Apple/Ipad Downloads

Other News: Top Downloads \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

Social: Facebook \ YouTube \ Twitter \ Tumblr \ Pintrest \ RSS Feeds