我有这个命令按钮,我需要使用 Bootstrap 3 添加一个图标。
<h:commandButton id="logoutButton" action="#{loginController.logout()}" class="btn btn-primary" style="margin-top: 10px;margin-left: 10px;" value="Log Out"></h:commandButton>
由于 bootstrap 3 原因,该图标位于 span 标记中,因此我尝试将其添加到命令按钮中的 value 属性,如下所示:
<h:commandButton id="logoutButton" action="#{loginController.logout()}" class="btn btn-primary" style="margin-top: 10px;margin-left: 10px;" value="<span class="glyphicon glyphicon-log-out"></span>Log Out"></h:commandButton>
我遇到了一个错误,我想我无法在 value 属性中添加 html 标签,有没有一种简单的方法可以做到这一点?
您不能将标记放入value
JSF 组件的属性。您应该像在普通 HTML 中一样将标记放入标记主体中。然而,这并不受<h:commandButton>
(原因很简单,因为它会生成一个<input>
元素和任何子元素最终都会出现无效的 HTML)。它将被渲染after生成的<input>
元素。
只需使用<h:commandLink>
反而。虽然它生成一个<a>
元素,Bootstrap CSS 也只是supports http://getbootstrap.com/2.3.2/base-css.html#buttons它以及对btn
风格类。
<h:commandLink id="logoutButton" action="#{loginController.logout}" styleClass="btn btn-primary">
<span class="glyphicon glyphicon-log-out"></span>Log Out
</h:commandLink>
(注意我修正了错误class
属性为styleClass
)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)