/ Published in: CSS
                    
                                        
Thanks to Brunildo.org for this: http://www.brunildo.org/test/img_center.html
                
                            
                                Expand |
                                Embed | Plain Text
                            
                        
                        Copy this code and paste it in your HTML
The markup:
<div class="wraptocenter"><span></span><img src="..." alt="..."></div>
The CSS:
<style type="text/css">
.wraptocenter {
display: table-cell;
text-align: center;
vertical-align: middle;
width: ...;
height: ...;
}
.wraptocenter * {
vertical-align: middle;
}
/*\*//*/
.wraptocenter {
display: block;
}
.wraptocenter span {
display: inline-block;
height: 100%;
width: 1px;
}
/**/
</style>
<!--[if lt IE 8]><style>
.wraptocenter span {
display: inline-block;
height: 100%;
}
</style><![endif]-->
URL: http://www.brunildo.org/test/img_center.html
Comments
 Subscribe to comments
                    Subscribe to comments
                
                