如何在GWT代码中将样式设置为重要?

Muh*_*edy 5 gwt coding-style

我需要在GWT代码中在运行时设置以下样式:

margin: 0 0 0 -6px !important;

我尝试过以下哪些不起作用:

Style style = htmlProductSearch.getElement().getStyle();
style.setProperty("margin", "0 0 0 -6px !important");
Run Code Online (Sandbox Code Playgroud)

但是,当我!important从字符串中删除它时,它可以工作..但我迫切需要使这种风格很重要.

我也使用了setter方法,setMarginxxxx但也没有用.

谢谢.

And*_*res -1

好吧,首先我必须阻止您使用该!important子句,因为它破坏了级联的相同概念。

但如果你没有其他选择,你可以让它工作删除速记风格。这应该适合你:

margin-left: -6px !important;
Run Code Online (Sandbox Code Playgroud)