Sponsored By

kingdutch

Firefox Centering?

Recommended Posts

Ok well erhm.. I want to center my container. I've done it loads of times. But I can't get it right this time. Internet Explorer does center but FireFox doesn't. I prolly have an error in my code but I can't figure it out right now.

/* MAIN PAGE SETUP */
body
{
text-align: center;
background-color: gray;
}
#container
{
[u][b]margin: 0 auto;[/b][/u]
width: 860px;
background-color: #006;
}

/* LOGO */
#logo
{
width: 860px;
height: 200px;
background: url('images/logo.jpg');
}

/* NAVIGATION */
.navbar
{
padding-top: 5px;
padding-bottom: 3px;
width: 100%;
background: url('images/button.jpg');
}
.navbar ul {
padding: 0px;
margin: 0px;
display: inline;
}
.navbar li {
list-style: none;
display: inline;
margin: 0px;
padding: 0px;
}
.navbar li a
{
width: 100px;
padding-top: 5px;
padding-bottom: 3px;
padding-left: 10px;
padding-right: 10px;
color: #FFFFFF;
font-family: arial;
font-size: 20px;
font-weight: bold;
text-decoration: none;
background: url('images/button.jpg');
}
.navbar li a:hover {
background: url('images/button_hover.jpg');
}

/* CONTENT */
#content
{
margin-left: auto;
margin-right: auto;
text-align: left;
min-height:500px;
height:auto !important;
height:500px;
}

That's my CSS

Thanks alot

*kingdutch waves at Jeff, Go besttechie!

SOLVED: placed a margin: 0 auto; in the container (Works for firefox somehow :mellow: )

Edited by kingdutch

Share this post


Link to post
Share on other sites

Setting the left and right margins to 'auto' is the standard way to centre a block and it should work in all remotely CSS compliant browsers. (everything except IE)

text-align should ONLY apply to inline text within the applicable element (Check the W3C spec if you want). But IE centres block children as well. This is wrong, simply thinking about it should make it obvious why as combining these two different functions makes the whole mechanism far less flexible. Centring just one block in IE requires that you wrap it in an extra element.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now