Reputation: 10695
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.
I can not mentioned width and height of div or image.
I can not use margin-top in pixels.
Here is my jsfiddle.
Upvotes: 0
Views: 110
Reputation: 15609
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.
Upvotes: 1
Reputation: 2099
Will background image technique fit your needs?
background: url(my-image.jpg) center center no-repeat;
Upvotes: 0