Javascript 方向改变不起作用
当我旋转我的设备时,我试图获得图像的大小和位置,但它总是显示相同Javascript 方向改变不起作用,javascript,device-orientation,Javascript,Device Orientation,当我旋转我的设备时,我试图获得图像的大小和位置,但它总是显示相同 $(window).bind('orientationchange', function(evt) { var height = $('#imgg').height(); var width = $('#imgg').width(); alert(height); alert(width); var position = $('#imgg').position(); alert('
$(window).bind('orientationchange', function(evt) {
var height = $('#imgg').height();
var width = $('#imgg').width();
alert(height);
alert(width);
var position = $('#imgg').position();
alert('left: ' + position.left + ', top: ' + position.top);
});
当然,当你旋转设备时,大小和位置是一样的。你期望发生什么?屏幕的宽度/高度会改变,但页面上的单个元素不会改变。嗨,Dave,当设备一直旋转时,大小会改变,因为我认为css媒体查询会改变位置,顶部和左侧…哦,这很有意义。你能用你的css和JSFIDLE来演示这一点吗?