GWT - TabLayoutPanel 样式问题
我想使用 TabLayoutPanel
实现水平导航栏,并使用自定义样式来满足我的需求。
但我不知道如何覆盖 default
样式。这是 UiBinder
模板:
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
xmlns:g="urn:import:com.google.gwt.user.client.ui">
<ui:style>
.gwt-TabLayoutPanel .gwt-TabLayoutPanelHeader {
background-color: red;
padding: 0;
margin: 0;
}
</ui:style>
<g:TabLayoutPanel barHeight="3.75" barUnit="EM">
<g:tab>
<g:header>Latest</g:header>
<g:Label>Latest Activities</g:Label>
</g:tab>
<g:tab>
<g:header>Patients</g:header>
<g:Label>Patients</g:Label>
</g:tab>
</g:TabLayoutPanel>
</ui:UiBinder>
这不起作用。但是我如何引用默认样式呢?
I want to implement a horizontal navbar using a TabLayoutPanel
, using custom styling to fit my needs.
But I don't know how to override the default
styling. Here's the UiBinder
template:
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
xmlns:g="urn:import:com.google.gwt.user.client.ui">
<ui:style>
.gwt-TabLayoutPanel .gwt-TabLayoutPanelHeader {
background-color: red;
padding: 0;
margin: 0;
}
</ui:style>
<g:TabLayoutPanel barHeight="3.75" barUnit="EM">
<g:tab>
<g:header>Latest</g:header>
<g:Label>Latest Activities</g:Label>
</g:tab>
<g:tab>
<g:header>Patients</g:header>
<g:Label>Patients</g:Label>
</g:tab>
</g:TabLayoutPanel>
</ui:UiBinder>
This doesn't work. But how can I reference the default styles?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
为了详细说明 atamur 的答案,他建议的第二个选项实际上是两个选项中更好的一个,特别是如果您所有其他样式都是使用 UiBinder 或客户端捆绑包设置的。基本上,您可以在初始
标记下方添加以下行:问题是 GWT 混淆了您在 UiBinder 模板中定义的样式规则。因此,当您编写“gwt-TabLayoutPanel”时,它会被混淆为“GMDW0RHDH”之类的内容,然后它永远不会应用于 TabLayoutPanel 的元素。添加“@external”会禁用这种混淆,并允许按照您的预期应用 UiBinder 中的样式。
To elaborate on atamur's answer, the second option he suggests is really the better of the two, especially if all your other styles are set using UiBinder or client bundles. Basically, you add the following line below your initial
<ui:style>
tag:The problem is that GWT is obfuscating the style rules you define in your UiBinder template. So when you write "gwt-TabLayoutPanel", that gets obfuscated to something like "GMDW0RHDH", which is then never applied to the elements of your TabLayoutPanel. Adding "@external" disables this obfuscation, and allows the styles in UiBinder to be applied as you'd expect.
附加一个单独的CSS,我认为 - 内联样式可与同一模板中的 {style.xyz} 一起使用。其实还有第二种解决方案。如果您坚持将其放在 ui.xml 中 - 使用外部作用域:http ://code.google.com/webtoolkit/doc/latest/DevGuideClientBundle.html#External_and_legacy_scopes
attach a separate css i think - inline styles are for use with {style.xyz} in the same template. Actually there's a second solution. If you insist on having it in the ui.xml - use external scope: http://code.google.com/webtoolkit/doc/latest/DevGuideClientBundle.html#External_and_legacy_scopes
或者您可以简单地将
!important
添加到您的样式定义中...Or you could simply add
!important
to your style definitions...这是一个有效的示例
http://code.google.com/p/salvadordiaz/source/browse/trunk/gwt-exception-handler/src/fr/salvadordiaz/gwt/ client/BlocImage.ui.xml?spec=svn56&r=56
here's an example that works
http://code.google.com/p/salvadordiaz/source/browse/trunk/gwt-exception-handler/src/fr/salvadordiaz/gwt/client/BlocImage.ui.xml?spec=svn56&r=56
经过一番研究后,我使用了下面的方法并且它有效...我正在使用 GWT 2.5
after some research i used the below approach and it worked...i am using GWT 2.5
如果你想查看 GWT css 文件是如何声明的:
如果需要,您可以更改主题。
If you want to see how GWT css file is declare:
You can change the theme if you want.