我假设这是可能的,但我可能错了。
我正在练习制作移动网站,我想要以下2个功能的组合- Javascript缩小菜单栏时向下滚动。媒体查询可在方向为横向时显示更大的菜单栏。
我有两个的代码- Javascript -
<script>
$(document).scroll(function(){
if ($(this).scrollTop()>1){
// animate fixed div to small size:
$('.container').stop().ani
我正在写一些jQuery代码,我想要检测移动设备的方向,无论是纵向还是横向。
我已经尝试了while语句,但它们不断地向我发送测试警报,但都无济于事。
我的jQuery:
function test() {
if (window.matchMedia("(orientation: portrait)").matches) {
alert('You are in portrait!');
}
else if (window.matchMedia("(orientation: landscape)").matches) {