Modify Style from GWT

前端 未结 2 657
不知归路
不知归路 2021-01-04 01:45

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:

publi         


        
相关标签:
2条回答
  • 2021-01-04 02:24

    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.

    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.

    0 讨论(0)
  • 2021-01-04 02:28

    What about using style classes? I mean, you can write a style class like this:

    .someClass {
        position:absolute;
        top:0px;
        left:0px;
    }
    

    And then add the style class to the TextArea

    ta.addStyleName("someClass");
    

    It will help you to write a more concise code, without inline styling that could be difficult to maintain.

    0 讨论(0)
提交回复
热议问题