Christopher
Christopher

Reputation: 895

CSS Margins Auto not Centering Floated Element

I am having a problem centering a div element. The div element that I am trying to center has the following styles applied to it:

width: 60%;
float:right;
margin-left: auto;
margin-right: auto;
min-width: 300px;

The only parent tag is the body tag which has the following styles applied to it:

width:100%;
overflow-x:hidden;

Instead of being centered, the element is aligned to the right. I previously had the element set to "float:left" and I didn't have a problem centering it, but when I changed it to "float:right" the element was no longer centered.

Upvotes: 1

Views: 4124

Answers (2)

brenjt
brenjt

Reputation: 16297

Remove float: right; from the styles.

Upvotes: 1

Austin S.
Austin S.

Reputation: 304

you need to remove the float:right

Upvotes: 5

Related Questions