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

允我心安 提交于 2019-12-10 11:42:06

问题


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?


回答1:


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.




回答2:


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;
}



回答3:


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.



来源:https://stackoverflow.com/questions/7832553/font-size-for-gwt-textbox-and-button-cant-be-set

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!