有什么方法可以获取GWT中小部件的position属性值?
我已经尝试过widget.getElement.getStyle().getPosition()
,但是它总是返回一个空字符串。
谢谢
最佳答案
您可以编写使用document.defaultView.getComputedStyle
的本机方法。
public static native String getComputedPosition(Element element) /*-{
return document.defaultView.getComputedStyle(element, null)["position"];
}-*/;
这适用于大多数现代浏览器。
参考:http://www.w3.org/TR/DOM-Level-2-Style/css.html#CSS-OverrideAndComputed