我试图在屏幕的中心定位一个元素,我可以在chrome和safari上实现,但在firefox上jquery定位是不会发生的,除非我调整窗口的大小我的jquery脚本是这样的:
$(window).on('ready resize', function(){
var windowH = $(window).height();
var lopos = $('.banner1').children('img').height()/2;
var centerPos = $('.banner1').children('img').width()/2;
var sponsor_place_width = $('#s_place').width();
$('.logo').children('img').css('top', lopos);
$('.sponsor_place').css('top', lopos - $('#s_place').outerHeight()/2 +$(document).scrollTop());
$('.sponsor_place').css('left', centerPos/2);
});有没有办法在firefox上解决这个问题?
发布于 2013-05-22 15:03:23
jQuery的$(window).height()对文档类型很敏感。试试<!doctype html>。您使用的是jquery 1.8和firefox 16以下版本吗?
在火狐使用中警告$(window).height()的值
$('#s_place').outerHeight({margin: true});并在所有浏览器中提示此问题
发布于 2013-05-22 18:41:29
.center
{
margin:0 auto;
}在中心添加你想要的图片标签的类中心。
https://stackoverflow.com/questions/16685290
复制相似问题