1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
<!doctype html> <html> <head> <meta charset="UTF-8"> <meta name="Generator" content="EditPlus®"> <meta name="Author" content=""> <meta name="Keywords" content=""> <meta name="Description" content=""> <title>Document</title> <style type="text/css"> @media screen and (orientation:portrait) { body{color:red} } @media screen and (orientation:landscape) { body{color:green;} } </style> </head> <body> 横屏竖屏测试。 </body> </html> <script type="text/javascript"> window.addEventListener('orientationchange', function(event){ if ( window.orientation == 180 || window.orientation==0 ) { alert("竖屏"); } if( window.orientation == 90 || window.orientation == -90 ) { alert("横屏"); } }); </script> |