我正在尝试修复一个jquery问题,我的代码是
<script language="javascript">
$(document).ready(function() {
//if the document is ready
$('#img').load(function() {
//if the image is loaded
pic_real_height = this.height;
//finding the height of the image
$('#img').css('margin-top', 150 - pic_real_height / 2 + 'px'); //setting the margin-top to align the image verticall middle in the container<br>
});
});
</script>
此脚本适用于除IE和Opera之外的所有浏览器,如何解决此问题? 实际上我想在容器(div)
中垂直设置图像谢谢你们
答案 0 :(得分:1)
试
pic_real_height = $(this).height();