How to vertically align an image inside a div

Possible duplicate:
How to vertically align the image

The image is resized, but the div is fixed.

This is CSS, but not working. Is it possible to achieve this without using the CSS background function.

This is the CSS class in which the image is pasted.

.PI { top: 25px; position: absolute; width: 239px; height: 120px; line-height:120px; text-align: center; left:-2px; border-top: 1px solid #f7f7f7; background: #b5aeb1; background: -webkit-gradient(linear, left top, left bottom, from(#d9d9d9), to(#b5aeb1)); background: -webkit-linear-gradient(top, #d9d9d9, #b5aeb1); background: -moz-linear-gradient(top, #d9d9d9, #b5aeb1); background: -ms-linear-gradient(top, #d9d9d9, #b5aeb1); background: -o-linear-gradient(top, #d9d9d9, #b5aeb1); -webkit-border-radius: 8px; -moz-border-radius: 8px; border-radius: 8px; -webkit-box-shadow: rgba(0,0,0,1) 0 1px 0; -moz-box-shadow: rgba(0,0,0,1) 0 1px 0; box-shadow: rgba(0,0,0,1) 0 1px 0; text-decoration: none; vertical-align: middle; } .PI img { margin: auto; vertical-align: middle; } 
+60
html css image vertical-alignment
Sep 07 '11 at 15:31
source share

No one has answered this question yet.

See similar questions:

1338
How to vertically align an image inside a div
2
Vertical align img in DIV
2
Vertical alignment of img element inside div
one
How to put an image in a div tag
0
vertical alignment: image in div
0
Image in DIV - Vertical Centering
0
Height The automatically calculated height is incorrect, so the background does not work - ASP.net 4.0 - Used Master Page
-one
My jQuery IMG Center script doesn't work in Chrome and Safari, but IE works?

or similar:

4863
How to turn off text highlighting
4078
How to center <div> horizontally?
2167
How to vertically center text using CSS?
1866
Align text vertically next to image?
1338
How to vertically align an image inside a div
1293
How to vertically center a div for all browsers?
1264
How can I automatically resize the image to fit the div container?
1082
How to align text vertically in a div?
1054
How to align div contents to bottom
702
How to vertically align elements in a div?



All Articles