Lexy Feito
Lexy Feito

Reputation: 290

firefox not centering main div

Im trying to center a main div using margin:0px auto; but it wont work in firefox. It works in Chrome and IE any idea why this happend.

css:

#mami{


width:1200px;

margin:0px auto;


}

html:

<body>

<div id='mami'>
   <h1>Center Me</h1>
</div>

</body>

Upvotes: 1

Views: 2844

Answers (3)

Chris Herbert
Chris Herbert

Reputation: 6295

Your div is centered fine in Firefox. http://jsfiddle.net/nTXeq/2/

enter image description here

If you want to center the text within the div, you'll need to target that specifically:

#mami {
text-align: center;
}

Upvotes: 2

Matt Clark
Matt Clark

Reputation: 28619

Set up a DIV around this with a name of like wraper with a width of 100%. Then center this element inside f that using:

HTML:

<div id="globalContainer">
    <div id="mami">
        This is some text!
    </div>
</div>

CSS:

#globalContainer{
    width:100%;
}

#mami{
    margin-left:auto;
    margin-right:auto;
    width:1200;
}

Upvotes: 0

webdev
webdev

Reputation: 339

try putting without px like margin: 0 auto; but you have to add something inside the div tag or else nothing will show and you have nothing to see.

<style>.asdf{background:silver;width:1200px;margin:0 auto;height:20px}</style><div class="asdf">Should Center</div>

Upvotes: 0

Related Questions