syrkull
syrkull

Reputation: 2344

centering float

I want the picture plus the gray background to be centered.

The body's style is set like this:

body {margin-left:auto;margin-right:auto;width:1000px;}

The div for the picture is this:

{width:auto;margin-left:auto;margin-right:auto;float:right;}

The image style is this:

{border:0px;padding:0px;margin:0px;}

If I removed the float the gray border around the image will fill all the page. and I do not want to specify a certain width for the border because some images are big and some are small.

I need help centering the image!

Upvotes: 0

Views: 146

Answers (2)

thirtydot
thirtydot

Reputation: 228302

  • Add text-align: center to #chpheader, and remove float: right.
  • Add display: inline-block to <div style="text-align:center;background-color:#DCDEDD;margin-top:20px;border-radius: 20px;">.
  • If you need IE6/7 compatibility, instead add display: inline-block; *display: inline; zoom: 1.

You should not be using inline styles.

Upvotes: 4

Grigor
Grigor

Reputation: 4059

image style should be margin:0px auto not just margin: 0px

Upvotes: 0

Related Questions