Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IE7 vertically align middle - not working

Tags:

html

css

Please find below the link,

http://jsfiddle.net/anglimass/Y8AvM/

I just wanna my div come's vertically align middle ie7 also.

Can anybody help?

Thanks


Sorry guys,

I find out one good solution Please see below the link,

http://jsfiddle.net/anglimass/ct4tx/

Thanks,

Ref:http://css-tricks.com/snippets/css/exactly-center-an-imagediv-horizontally-and-vertically/

like image 883
anglimasS Avatar asked Jun 12 '12 14:06

anglimasS


People also ask

How do I center my inner div vertically?

Vertically centering div items inside another div Just set the container to display:table and then the inner items to display:table-cell . Set a height on the container, and then set vertical-align:middle on the inner items.

What is the default vertical alignment?

The default value of vertical-align (if you declare nothing), is baseline. Images will line up with the text at the baseline of the text.


1 Answers

It's not working in IE7 because IE7 does not support display: table-cell.

I've even told you this before.

Here's an alternative vertical centering technique that does work in IE7: How to vertically align an image inside div

Here's the simplest version of the technique from the above answer applied to your code: http://jsfiddle.net/thirtydot/Y8AvM/1/

HTML:

<div class="inlay">
    <span class="helper"></span><img src="http://goldstudios.net/uploader/uploads/Wildebeest_$1$2ryes3hf$Fl0tEsFaORwBW2seye9qN0.jpg" />
</div>​

CSS:

html, body {
    height: 100%;
    background: #ddd;
}
.inlay {
    height: 100%;
    text-align: center;
}

.inlay img {
    vertical-align: middle;
}
.helper {
    display: inline-block;
    height: 100%;
    vertical-align: middle;
}

It works in all modern browsers, and of course, IE7.

like image 175
thirtydot Avatar answered Nov 11 '22 16:11

thirtydot