我正在尝试为Firefox OS创建一个简单的文本编辑器,在该编辑器中,我使用testarea
作为用户的文本字段。当我使用模拟器时,当我将屏幕方向从纵向更改为横向或横向时,我需要textarea
自动更改其方向并获得全屏大小。但每次我改变方向时,我都需要重新加载应用程序:(
如果我尝试CCD_ 3,结果是未定义的。
我用来获取屏幕尺寸的波纹管代码
HTML:
<textarea id="input-text" onfocus="TextareaOnFocus()" onblur="TextareaRealeseFocus()"></textarea>
Javascript:
var textAreaSize = document.getElementById("input-text");
textAreaSize.style.height = screen.height - 74 + "px"; // -74, so that the field is not edge to edge
textAreaSize.style.width = screen.width - 21 + "px"; // -21, so that the field is not edge to edge
有没有办法改变键盘的大小,因为它覆盖了一半的屏幕,所以我的文本文件变得很小。
只需在CSS中设置文本区域的大小,因为我们现在有了calc和vw/vh等很酷的东西。
#input-text {
height: calc(100vh - 74px);
width: calc(100vw - 21px);
}
旋转时也会自动工作。
screen.orientation
不起作用的原因是因为目前API方向是非标准的,所以您需要在前面加上moz
。F.e.:screen.mozOrientation
运行良好。