[英]How to style Anchor in GWT?
How can I add style for Anchor in GWT using UIBinder? 如何使用UIBinder在GWT中为Anchor添加样式? I have following piece of code in UiBinder template XML:
我在UiBinder模板XML中有以下代码:
<g:Anchor ui:field="forgotPassLink">Forgot password?</g:Anchor>
I know that .gwt-Anchor { } is used for styling this widget, but still no idea how to style hover effects. 我知道.gwt-Anchor {}用于为这个小部件设置样式,但仍然不知道如何设置悬停效果的样式。 In normal CSS it would go like this:
在普通的CSS中,它会像这样:
a:link {color:#FF0000;} /* unvisited link */
a:visited {color:#00FF00;} /* visited link */
a:hover {color:#FF00FF;} /* mouse over link */
a:active {color:#0000FF;} /* selected link */
Do I have to handle this with BlurEvent and FocusEvent handlers on Anchor? 我是否必须使用Anchor上的BlurEvent和FocusEvent处理程序来处理这个问题? If so ...that is boilerplate code..
如果是这样......那就是样板代码..
Use the same CSS pseudo-classes with the gwt-Anchor
class: 与
gwt-Anchor
类使用相同的CSS伪类:
.gwt-Anchor:link {color:#FF0000;}
.gwt-Anchor:visited {color:#00FF00;}
.gwt-Anchor:hover {color:#FF00FF;}
.gwt-Anchor:active {color:#0000FF;}
You can also use a.gwt-Anchor
but it isn't strictly necessary. 您也可以使用
a.gwt-Anchor
但这不是必需的。
If you are using uibinder with the gwt HyperLink, it can be done like this: 如果您将uibinder与gwt HyperLink一起使用,可以这样做:
<ui:style>
.mystyle a:link {
color:#3F3F3F;
text-decoration:none;
}
</ui:style>
<g:FlowPanel>
<g:Hyperlink styleName='{style.mystyle}'/>
</g:FlowPanel>
Define your style like this: 像这样定义你的风格:
<ui:style>
.menuItem a:link {color: white;}
.menuItem a:visited {color: white;}
.menuItem a:hover {color: white;}
.menuItem a:active {color: white;}
</ui:style>
And use it like this: 并像这样使用它:
<g:Hyperlink styleName="{style.menuItem}" targetHistoryToken="home">Home</g:Hyperlink>
Does this work (using UIBinder style names) ? 这是否有效(使用UIBinder样式名称)?
<ui:style>
.a:link { color: #FF0000; }
.a:visited { color: #00FF00; }
.a:hover { color: #FF00FF; }
.a:active { color: #000FF; }
</ui:style>
<g:HTMLPanel>
<g:Anchor ui:field="forgotPassLink" styleName="{style.a}">Forgot password?</g:Anchor>
</g:HTMLPanel>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.