sark9012
sark9012

Reputation: 5717

Centering the div

Simple one that doesn't seem to want to work..

I want to centre a div inside a 100% wide div.

HTML.

<div id="body-outside">
    <div id="body-inside">
        content
    </div>
</div>

CSS.

#body-outside{
    width:100%;
    float:left;
    background-color:#F7B3DA;
}

#body-inside{
    width:1280px;
    margin:0 auto;
    background-color:#F7B3DA;
    float:left;
}

The content is staying on the left of the screen at the moment. Any ideas?

Thanks.

Upvotes: 0

Views: 92

Answers (2)

richardm12181
richardm12181

Reputation: 21

You may also want to think about using text-align: center in the body outside portion.

Upvotes: 2

Daniel Li
Daniel Li

Reputation: 15379

Get rid of float:left;. This pushes it to the left despite setting the margin to auto.

Upvotes: 5

Related Questions