: 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
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?
More posts by @Sherry384
1 Comments
Sorted by latest first Latest Oldest Best
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!
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.