Umesh Patil
Umesh Patil

Reputation: 10695

vertical align Image Block at middle

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.

Upvotes: 0

Views: 110

Answers (2)

Paulo R.
Paulo R.

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

skovalyov
skovalyov

Reputation: 2099

Will background image technique fit your needs?

background: url(my-image.jpg) center center no-repeat;

Upvotes: 0

Related Questions