*Author

Active members:
dannlea(2) Paddoo(2)

Offline dannleaTopic starter

  • Newbie
  • *
  • Posts: 5
  • Country: ca
  • Reputation Power: 0
  • dannlea hides under a Cloak.
  • New to Elements
[HTML / CSS] Why won't this center? https://elementscommunity.org/forum/index.php?topic=48954.msg1066132#msg1066132
« on: May 03, 2013, 04:52:35 pm »
So basically I have two divs that I want to center in the middle of the page. They extend from the top to bottom, no matter the page size.  Here's my code:
Code: [Select]
html, body, #backdrop, #content {
min-height: 100%;
height: 100%;
}
html {
background: url(img/bg.png) fixed;
width: 850 px;
margin: auto 0px;
}

body {
width: 850 px;
margin: auto 0px;
}

#backdrop {
background: #2c0000;
width: 850px;
margin: auto 0;
}
#content {
background: #000;
width: 830px;
margin: auto 0px;
}

The HTML is set up perfectly. I have the HTML inside the divs in the correct order.

It goes HTML > BODY > BACKDROP > CONTENT

So it all works great. Except... It doesn't center. All the divs are over to the left.

Anyone know why?

Thanks,
Dan
« Last Edit: May 03, 2013, 04:54:20 pm by dannlea »
Dan | Web Designer | HTML Advocate

Offline Paddoo

  • Jr. Member
  • **
  • Posts: 101
  • Country: fr
  • Reputation Power: 2
  • Paddoo is a Spark waiting for a buff.
  • Bwah.
  • Awards: Slice of Elements 4th Birthday Cake
Re: [HTML / CSS] Why won't this center? https://elementscommunity.org/forum/index.php?topic=48954.msg1066137#msg1066137
« Reply #1 on: May 03, 2013, 05:14:12 pm »
It's because you switched the margins order. When using only two arguments, it's vertical first, then horizontal.
So "margin 0 auto;" should work.
<Chapuz> you are a crazy guy, you know

Offline dannleaTopic starter

  • Newbie
  • *
  • Posts: 5
  • Country: ca
  • Reputation Power: 0
  • dannlea hides under a Cloak.
  • New to Elements
Re: [HTML / CSS] Why won't this center? https://elementscommunity.org/forum/index.php?topic=48954.msg1066306#msg1066306
« Reply #2 on: May 04, 2013, 05:01:55 am »
I had my doubts because I figured I would have tried something so obvious, seeing that I have been coding for 4+ years now... Of course I didn't! Haha, thank you greatly. Much appreciated.
Dan | Web Designer | HTML Advocate

Offline Paddoo

  • Jr. Member
  • **
  • Posts: 101
  • Country: fr
  • Reputation Power: 2
  • Paddoo is a Spark waiting for a buff.
  • Bwah.
  • Awards: Slice of Elements 4th Birthday Cake
Re: [HTML / CSS] Why won't this center? https://elementscommunity.org/forum/index.php?topic=48954.msg1066307#msg1066307
« Reply #3 on: May 04, 2013, 05:04:56 am »
You're welcome.  :)
<Chapuz> you are a crazy guy, you know

 

blarg: