Mobile app version of vmapp.org
Login or Join
Sherry384

: Cannot horizontally center fixed width div in IE I am creating a template for a website. The example is at Framework Login Page The main CSS sheet is at: master.css I am trying to center the

@Sherry384

Posted in: #Css #Html

I am creating a template for a website.

The example is at Framework Login Page
The main CSS sheet is at: master.css

I am trying to center the main parent div.

I am using
#body {
width: 100%;
background: url('pathtoimage.png');
}
#inner_body {
width: 800px;
margin: auto;
}

<body>
<div id="body">
<div id="inner_body"></div>
</div>
</body>


What could the issue be?

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Sherry384

1 Comments

Sorted by latest first Latest Oldest Best

 

@Kaufman445

It depends on what browser you're using. Mozilla Firefox will need margin: auto; inside of the CSS (As you have now), but IE is the short-bus-rider that needs special attention...
#body {
width: 100%;
background: url('pathtoimage.png');
**margin: auto;
text-align: center;**
}
#inner_body {
width: 800px;
margin: auto;
}
.
.
.


For internet explorer, you have to add in text-align: center; to your css, and I noticed that you didn't have margin: auto; in the parent element that you wanted to center. Adding the simple attribute align="center" into the tag itself works in most cases.

Hope this helps!

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme