I used this code in my project:
#HomePage {
background-image:url('../../Includes/Images/RestBg1.png');
width:790px;
height:514px;
margin:0 auto;
text-align:center;
vertical-align: middle;
overflow: hidden;
margin:0 auto;
}
This vertical center alignment is working fi开发者_开发问答ne in FF, Safari and IE8 but is not properly working in IE7.
We could use more context, like the HTML... But vertical-align isn't really for aligning text vertically, except when rendering in table-cell mode. If it is a regular block or inline, you're only practical solution is setting padding or line-height, though those only work when you know the height of the element.
Your other solution would be looking at the element height in JavaScript after page load, and doing some math to figure out what kind of CSS padding to set.
精彩评论