-3

I'm trying to align this image in the center of the page. I've tried " (in the body)" "text-align:center; and display:inline-block; (in the css)" but they don't work.

Here's the JSFiddle: http://jsfiddle.net/4TtHR/1/

Here's the CSS:

figure {
  display: inline-block;
  position: relative;
  float: left;
  overflow: hidden;
  margin: 0 20px 20px 0;
}
user2680614
  • 430
  • 3
  • 12
  • 25

2 Answers2

1
figure {
display: block;
position: relative;
overflow: hidden;
margin: 0 auto;
width: 50%;
}
IRONLORD
  • 163
  • 1
  • 12
1

You are trying to center a floated element.

You can simply wrap it in a div, set it to display:inline-block in order to contain the child element. Then apply text-align:center to the parent in order to center the div.

jsFiddle here

Josh Crozier
  • 219,308
  • 53
  • 366
  • 287