javascript - 微信网站,input标签旋转90度后键盘如何横屏弹出
大家讲道理
大家讲道理 2017-04-10 17:46:33
[JavaScript讨论组]

因为做一个横屏的微信游戏,有一个输入玩家信息的地方,要横屏展示。
将input旋转90度后键盘还是竖屏弹出,怎么能横屏弹出

大家讲道理
大家讲道理

光阴似箭催人老,日月如移越少年。

全部回复(3)
PHPz

键盘的弹出方式只取决于设备当前所处的状态(是横屏还是竖屏)。你虽然在网页内部对输入框进行旋转,但是相对于系统来说,微信还是处于竖屏状态的。
我觉得让用户在竖屏下输入信息也是可以接受的,如果非要横屏下输,那只能自己弄一个虚拟键盘了(不过虚拟键盘又不方便处理中文输入的问题)。

伊谢尔伦

已有类似问题,请参考:

https://segmentfault.com/q/1010000002793002?_ea=209862

希望有所帮助~ :)

伊谢尔伦

w3c标准,不知道好用不好用;The Screen Orientation API

4.1 Locking the screen orientation

The steps for locking the screen orientation are as follows:

If the user agent does not allow the current browsing context to lock the screen orientation, the steps must stop here and return false. For example, a user agent might only allow browsing context in a fullscreen state to lock the screen orientation or browsing context with elevated privileges.
Let orientations be the list of locking orientations.
For each orientation in the orientations list, run the following sub steps:
If orientation isn't part of the allowed orientations, the steps must stop here and return false.
If orientation is portrait or landscape the value must be removed from orientations and every allowed orientations it is representing must be inserted in orientations.
If orientations isn't a supported orientations set, the steps must stop here and return false.
Return true and run the remaining steps asynchronously.
The user agent must lock the orientation to orientations.


// 强制竖屏
window.screen.lockOrientation([“portrait-primary”,“portrait-secondary”]);
// 强制横屏
window.screen.lockOrientation([“landscape-primary”,“landscape-secondary”]);
// 取消强制
window.screen.unlockOrientation();

PS:由于腾讯出品,不保证w3c好用;

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号