开发者

How to set style as important from within GWT code?

开发者 https://www.devze.com 2023-02-24 02:57 出处:网络
I\'ve the following style that I need to set at run-time from within GWT code: margin: 0 0 0 -6px !important;

I've the following style that I need to set at run-time from within GWT code:

margin: 0 0 0 -6px !important;

I've tried the following which didn't work:

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

However, 开发者_如何学编程when I removed the !important from the string, it works.. but I urgently need to make this style important.

Also I've used the setters methods setMarginxxxx but didn't work too.

Thanks.


htmlProductSearch.getElement().setAttribute("style","margin : 0 0 0 -6px !important");
Hope this should work.


Not a perfect solution but you can use the addStyleName to add a css style.

In this css style you can use the !important.

This will work I think


With elemental2 you can use

style.setProperty(propertyName, value, "important");


Well, first of all I must prevent you from using the !important clause, since it defeats the same concept of cascading.

But if you don't have other choice, you can make it work removing the shorthand sytle. This should work for you:

margin-left: -6px !important;
0

精彩评论

暂无评论...
验证码 换一张
取 消