1 Replies - 401 Views - Last Post: 07 October 2012 - 11:18 PM

#1 drodriguez  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 93
  • Joined: 03-October 12

why wont my div center?!

Posted 07 October 2012 - 11:08 PM

This has got to be a stupid mistake on my part. I cannot for the life of me figure out why my div will not center.

html

<html>
<head>
<title>Im Confused</title>

<link rel="stylesheet" type="text/css" href="styles.css" />
</head>

<body>

<div id="mbody">
   content
</div>
</body>
</html>



css

#mbody {
  position:relative;
  margin:0px;
  width:1000px;
  height:100px;
  border:2px solid red;
  margin-left:auto;
  margin-right:auto;
}



i have tried this with and without the position:relative and it changes nothing. i have a website that i had already figured out this problem. i figured i would just mimick the code to recreate it. i have failed misreably. after searching tutorials on how to center a div using margin-right/margin-left auto i have still failed. first person to point me to the errors of my pathetic ways will get to take the first turn in a game of roshambo.

Is This A Good Question/Topic? 0
  • +

Replies To: why wont my div center?!

#2 drodriguez  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 93
  • Joined: 03-October 12

Re: why wont my div center?!

Posted 07 October 2012 - 11:18 PM

i figured it out! no one gets to kick me in the... well nevermind that. apparently the ie im using ignores the margin auto code. i added the following to my css and it worked like a charm.

body
{
text-align: center;
}
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1