从GWT修改样式 [英] Modify Style from GWT

查看:115
本文介绍了从GWT修改样式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我执行了,但只有FF和chrome将textarea 0px从顶部和0px左移,但在IE
textarea处于默认位置。

I executed but only FF and chrome moves the textarea 0px from top and 0px from left but in IE textarea is in default position.

这里是我的代码:

Here is my code:

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;");
   }

}

有没有错误我以编程方式从GWT改变样式属性

is there any bug or how can i change style attribute programmatically from GWT ??

推荐答案

不要设置样式通过 setAttribute 。在JavaScript中,style属性实际上是一个数组。因此,取决于浏览器的智能程度,并理解你想设置样式属性,它可以通过设置 style 或不起作用。

Don't set style via setAttribute. In JavaScript the style attribute is actually an array. Thus depending on how smart the browser is and understands you want to set the style attributes it will work by setting style or won't work.

您应该分别通过 getElement()。getStyle()。setProperty()设置样式属性。或者使用特定方法,如: ta.getElement()。getStyle().setPosition(Position.ABSOLUTE)或通过setProperty方法: ta .getElement()。getStyle()。setProperty(position,absolute)。对于其他两个属性也是如此。请参阅 Style 类以了解支持哪些特定方法。

You should set style attributes individually via getElement().getStyle().setProperty(). Or use the specific methods, like: ta.getElement().getStyle().setPosition(Position.ABSOLUTE) or via the setProperty method: ta.getElement().getStyle().setProperty("position", "absolute"). And the same for the 2 other properties. See the Style class for what specific methods are supported.

这篇关于从GWT修改样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆