<script>
var width = document.documentElement.clientWidth;
var height = document.documentElement.clientHeight;
$app = $('#app');
if (width < height) {
console.log(width + " " + height);
$app.width(height);
$app.height(width);
$app.css('transform', 'rotate(90deg)');
$app.css('transform-origin', `${width / 2}px ${width / 2}px`);
}
var evt = "onorientationchange" in window ? "orientationchange" : "resize";
window.addEventListener(evt, function () {
setTimeout(function () {
var width = document.documentElement.clientWidth;
var height = document.documentElement.clientHeight;
$app = $('#app');
if (width > height) {
$app.width(width);
$app.height(height);
$app.css('transform', 'none');
$app.css('transform-origin', `${width / 2}px ${width / 2}px`);
} else {
$app.width(height);
$app.height(width);
$app.css('transform', 'rotate(90deg)');
$app.css('transform-origin', `${width / 2}px ${width / 2}px`);
}
}, 100)
}, false);
</script>
h5 强制横屏
最新推荐文章于 2025-01-03 08:15:09 发布