0

I need to align image at the middle of the page. I used margin:auto to align middle horizontally.

How do I align the div block middle vertically. I have below conditions to follow.

  1. I can not mentioned width and height of div or image.

  2. I can not use margin-top in pixels.

Here is my jsfiddle.

BoltClock
  • 665,005
  • 155
  • 1,345
  • 1,328
Umesh Patil
  • 10,059
  • 16
  • 48
  • 78
  • 1
    This is a common problem. Check out this question: http://stackoverflow.com/questions/79461/vertical-alignment-of-elements-in-a-div – alf Jul 14 '12 at 13:34

2 Answers2

1

You were doing it almost right. Here's your fixed fiddle http://jsfiddle.net/joplomacedo/cDD7m/4/

The thing is, you need an element with display: table wrapping one with display: table-cell for the table-cell to behave like it's supposed to.

João Paulo Macedo
  • 14,919
  • 4
  • 30
  • 40
0

Will background image technique fit your needs?

background: url(my-image.jpg) center center no-repeat;
skovalyov
  • 1,969
  • 1
  • 15
  • 12