<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事件来实时更新元素的宽度、高度及旋转角度。
部署运行你感兴趣的模型镜像
您可能感兴趣的与本文相关的镜像
Wan2.2-T2V-A5B
文生视频
Wan2.2
Wan2.2是由通义万相开源高效文本到视频生成模型,是有50亿参数的轻量级视频生成模型,专为快速内容创作优化。支持480P视频生成,具备优秀的时序连贯性和运动推理能力
334

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



