I have a full screen background image that maintains aspect ratio and works fine in all browsers, but not in Safari. I'm good at CSS, but at the moment I donβt know exactly what the problem is. It seems that Safari has problems maintaining the vertical center and creating gaps above and below:
<div id="bg"> <div style="display: table-cell"> <table cellpadding="0" cellspacing="0"> <tr> <td class="loading"><img src="images/home.jpg" /></td> </tr> </table> </div> </div>
CSS
html,body,#bg,#bg table,#bg td { width:100%; height:100%; overflow:hidden; position: relative } #bg div{ position:absolute; width:200%; height:200%; top:-50%; left:-50% } #bg td{ vertical-align:middle; text-align:center } #bg img{ min-height:50%; min-width:50%; margin:0 auto; display: table }
Any CSS cr hacking hub?
source share