如何更改 GWT 的小部件 CSS 值?
基本上,我喜欢默认主题小部件。但是,我需要更改 DecolatedStackPanel 小部件上的字体大小。
我认为应该可以这样:
decoratedStackPanel.getElement().getStyle().setProperty("fontSize", "12pt");
但是,“fontSize”不是属性的有效名称,并且我没有找到方法如何获取所有元素的属性。因此,我不知道正确的属性名称。
有什么想法吗?
请不要发布有关继承 widget 或编写自定义 CSS 的文章。我喜欢默认的,但字体大小。据我所知,这应该是可能的。
Basically, I like default theme widgets. However, I need to change font size on DecoratedStackPanel widget.
I think it should be possible with something like this:
decoratedStackPanel.getElement().getStyle().setProperty("fontSize", "12pt");
However, "fontSize" is not valid name for property and I didn't find way how to get all element's properties. Therefore, I don't know correct property name.
Any ideas?
Please, don't post about inheriting widget or writing custom CSS. I like default one but the font size. This should be possible afaik.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
fontSize 是正确的,最好的使用方法如下:
但我不确定这会产生你想要的结果。它设置整个面板上的字体大小,如果在子元素上设置了另一种字体大小,则该元素将使用该字体大小。在这种情况下,特定元素的 css 条目会更好。例如:(
!important 将强制使用此特定的字体大小设置,并且仅当您想确保使用此字体大小时才应使用。首先测试不使用)。
fontSize is correct, the best way to use is as follows:
But i'm not sure this will result in what you want. it sets the font size on the whole panel, and if another font size is set on a child element that one will be used in that element. In that case a css entry for the specific element would be better. For example:
(!important will force to use this specific font-size setting, and should only be used if you want to make sure this font-size is used. First test without).
您可以使用 DOM 类来设置样式属性。
You can use DOM class to set style attributes..
fontSize 将被转换为 font-size
fontSize would be translated to font-size