<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-09-30 14:22:04 发布
本文介绍了一种使用JavaScript根据设备方向自动调整网页元素显示方向的方法。具体实现中利用了document.documentElement.clientWidth和clientHeight属性来获取视口尺寸,并通过监听orientationchange或resize事件来实时更新元素的宽度、高度及旋转角度。
部署运行你感兴趣的模型镜像
您可能感兴趣的与本文相关的镜像
Facefusion
AI应用
FaceFusion是全新一代AI换脸工具,无需安装,一键运行,可以完成去遮挡,高清化,卡通脸一键替换,并且Nvidia/AMD等显卡全平台支持
334

被折叠的 条评论
为什么被折叠?



