我执行但只有FF和chrome从顶部移动textarea 0px,从左移动0px但在IE textarea中处于默认位置.
这是我的代码:
public class MyGWT implements EntryPoint {
TextArea ta= TextArea.wrap(DOM.getElementById("t"));
public void onModuleLoad() {
ta.getElement().setAttribute("style", "position:absolute;top:0px;left:0px;");
}
}
Run Code Online (Sandbox Code Playgroud)
是否有任何错误或如何从GWT以编程方式更改样式属性?
Hil*_*amp 29
不要设置style通过setAttribute.在JavaScript中,style属性实际上是一个数组.因此,根据浏览器的智能程度和理解你想要设置样式属性,它将通过设置style或不起作用来工作.
您应该单独设置样式属性getElement().getStyle().setProperty().或者使用特定的方法,例如:ta.getElement().getStyle().setPosition(Position.ABSOLUTE)或通过setProperty方法:ta.getElement().getStyle().setProperty("position", "absolute").对于其他2个属性也一样.请参阅Style类以了解支持的具体方法.
| 归档时间: |
|
| 查看次数: |
11875 次 |
| 最近记录: |