Font-size for GWT TextBox and Button can't be

2019-05-30 17:02发布

I have a GWT button and I want to change the font-size of it to 15pt. In my Project.css, I have set it's font-size.

.gwt-Button {
    font-size: 15pt;
}

But this CSS style doesn't change the font-size of my Button. Is there any other way I could change the font-size of my button?

3条回答
甜甜的少女心
2楼-- · 2019-05-30 17:29

If you're using a GWT theme, it might very well define the fond-size, so you have to make sure your stylesheet is either loaded after (so it redefines the font-size) or use a more specific selector (input.gwt-Button for instance).
It really depends how, when and where you load your stylesheet and/or the theme stylesheet.

Note that you can inherit the <theme-name>Resources module (e.g. CleanResources instead of Clean) to have the theme's resources copied to the output folder but not automatically loaded, and then load the stylesheet from your HTML host page (using a <link rel=stylesheet href=…> just like any stylesheet), so it's easier to put your custom styles after.

查看更多
再贱就再见
3楼-- · 2019-05-30 17:29

you should not use default stylenames like .gwt-Button because they can have precedence problems . You can set new stylename with .setStyleName("customButton") and then use it in CSS file.

example:

.customButton{
font-size: 15pt;
}
查看更多
我命由我不由天
4楼-- · 2019-05-30 17:34

You only have to add the !important flag to your style sheet like

.gwt-Button {
    font-size: 15pt !important;
}

Or use your own style name for your button, e.g. myButton.addStyleName("myButtonStyle"); in your code and

.myButtonStyle {
    font-size: 15pt !important;
 }

in your Project.css file.

This works the same way for your TextBox.

查看更多
登录 后发表回答