微信网站,input标签旋转90度后键盘如何横屏弹出

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

阅读 6.7k
4 个回答

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

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好用;

题主有解决方案了吗?求告知,同被这个问题困扰

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题