创建我自己的GWT Button CSS样式器

时间:2021-11-15 08:00:24

I want to set a custom background for all my Buttons in my GWT app. I'm using the standard GWT Button class. So ( As recommended by one of the guys in SO ) in my CSS file I have

我想在我的GWT应用程序中为我的所有按钮设置自定义背景。我正在使用标准的GWT Button类。所以(在我的CSS文件中由其中一个人推荐)我有

.gwt-Button
{
background-color: red;
}

However this does not get applied to my Button. Then I tried

但是这不适用于我的Button。然后我试了一下

myButton.setStyleName("gwt-Button");

Same result. I then changed the name of the style to "gwt.Button1" , set this as my style name and hey presto it works. So investigating why I couldn't modify the inbuilt CSS style I noticed that when I compiled my GWT project ( I'm using Eclipse ) that in my WAR folder there is a folder created called war/myModule/gwt/standard and in this folder are CSS files which contain the default GWT styles. ( At least that's my take on it ) So my question is how do I apply my own styling to gwt-Button and why are these css files being put in this folder and can I change these?

结果相同。然后我将样式的名称更改为“gwt.Button1”,将其设置为我的样式名称,并且嘿presto它的工作原理。所以调查为什么我不能修改内置的CSS样式我注意到当我编译我的GWT项目(我正在使用Eclipse)时,在我的WAR文件夹中创建了一个名为war / myModule / gwt / standard的文件夹,并在此文件夹中是包含默认GWT样式的CSS文件。 (至少这是我的看法)所以我的问题是我如何将自己的样式应用于gwt-Button,为什么这些css文件被放在这个文件夹中,我可以更改这些吗?

2 个解决方案

#1


1  

Project --->
|
Src
|
package com.xxxxx
|
|
folder(resources(any))
|
|
css(folder)
|
|
YourcssFile.css(write your css here )

Refer :https://developers.google.com/web-toolkit/doc/latest/DevGuideUiCss#cssfiles

And in GWT.xml file

并在GWT.xml文件中

<stylesheet src='css/YourcssFile.css' />

#2


2  

I think the below link should solve your problem

我认为以下链接应该可以解决您的问题

GWT theme style overrides my css style

GWT主题风格覆盖了我的CSS风格

If not revert back. Cheers :)

如果没有还原。干杯:)

#1


1  

Project --->
|
Src
|
package com.xxxxx
|
|
folder(resources(any))
|
|
css(folder)
|
|
YourcssFile.css(write your css here )

Refer :https://developers.google.com/web-toolkit/doc/latest/DevGuideUiCss#cssfiles

And in GWT.xml file

并在GWT.xml文件中

<stylesheet src='css/YourcssFile.css' />

#2


2  

I think the below link should solve your problem

我认为以下链接应该可以解决您的问题

GWT theme style overrides my css style

GWT主题风格覆盖了我的CSS风格

If not revert back. Cheers :)

如果没有还原。干杯:)