如何更改 GWT 的小部件 CSS 值?

发布于 2024-10-10 00:16:41 字数 368 浏览 0 评论 0原文

基本上,我喜欢默认主题小部件。但是,我需要更改 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

机场等船 2024-10-17 00:16:41

fontSize 是正确的,最好的使用方法如下:

decoratedStackPanel.getElement().getStyle().setFontSize(12, Unit.PT);

但我不确定这会产生你想要的结果。它设置整个面板上的字体大小,如果在子元素上设置了另一种字体大小,则该元素将使用该字体大小。在这种情况下,特定元素的 css 条目会更好。例如:(

.gwt-DecoratedStackPanel .gwt-StackPanelItem {
   font-size:12pt !important;
}

!important 将强制使用此特定的字体大小设置,并且仅当您想确保使用此字体大小时才应使用。首先测试不使用)。

fontSize is correct, the best way to use is as follows:

decoratedStackPanel.getElement().getStyle().setFontSize(12, Unit.PT);

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:

.gwt-DecoratedStackPanel .gwt-StackPanelItem {
   font-size:12pt !important;
}

(!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).

回眸一笑 2024-10-17 00:16:41

您可以使用 DOM 类来设置样式属性。

DOM.setStyleAttribute(decoratedStackPanel.getElement(), "fontSize", "12pt");

You can use DOM class to set style attributes..

DOM.setStyleAttribute(decoratedStackPanel.getElement(), "fontSize", "12pt");
鸵鸟症 2024-10-17 00:16:41

fontSize 将被转换为 font-size

fontSize would be translated to font-size

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文