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
  • 700,868
  • 160
  • 1,392
  • 1,356
Umesh Patil
  • 10,475
  • 16
  • 52
  • 80
  • 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
  • 15,297
  • 4
  • 31
  • 41
0

Will background image technique fit your needs?

background: url(my-image.jpg) center center no-repeat;
skovalyov
  • 2,069
  • 1
  • 16
  • 12