Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/420.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 方向改变不起作用_Javascript_Device Orientation - Fatal编程技术网

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来演示这一点吗?