横竖屏切换 页面布局 变化严重,使用媒体查询写两套css,- -
CSS
@media screen and (orientation: portrait) {
/* 竖屏 */
}
@media screen and (orientation: landscape) {
/* 横屏 */
}
JS
var d = window.matchMedia("(orientation: portrait)");
onMatchMeidaChange(d);
d.addListener(onMatchMeidaChange);
function onMatchMeidaChange(d) {
if(d.matches) { // 竖屏
} else { //横屏
}
}