移动端横屏

<style>

@media all and (orientation : landscape) {
/*横屏*/
.topbar,.caption,.profile,.recommend,.plovr-error-report {
display: none !important;
}
}
</style>


<script>
function orientationChange() {
if (typeof window.orientation != 'undefined') {
if (window.orientation == 180 || window.orientation == 0) {
eleMedia.style['height'] = '181px';
eleBody.scrollTop = 0;
}
if (window.orientation == 90 || window.orientation == -90) {
setTimeout(function () {
var height = Math.max(window.screen.height, window.screen.width) * 9 / 16;
eleMedia.style['height'] = height + 'px';
eleBody.scrollTop = (window.innerHeight - height) / 2;
}, 1);
}
}
}

window.addEventListener("onorientationchange" in window ? "orientationchange" : "resize", function () {
orientationChange();
}, false);


orientationChange();
</script>
posted @ 2016-01-20 17:32  djdliu  阅读(215)  评论(0编辑  收藏  举报