【发布时间】:2012-06-23 11:24:03
【问题描述】:
当一个按钮被创建时,ui-corner-all 类总是被应用。我尝试了以下方法:
<p:commandButton id="like" styleClass="ui-corner-right" />
但它没有用。在 Firebug 上,我看到了 ui-corner-all 和 ui-corner-right:
<div id="form1:like" type="button" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-icon-left ui-corner-right">
更新 1:
根据JMelnik的提示,我终于成功地将ui-corner-all的样式改为ui-corner-right,添加如下脚本:
<style type="text/css">
#myForm\:likeButton .ui-corner-all {
border-radius: 6px 0px 0px 6px !important;
}
</style>
并将<p:commandButton> 包裹在<h:panelGroup> 中,如下所示:
<h:form id="myForm">
<h:panelGroup id="likeButton">
<p:commandButton />
<h:panelGroup>
</h:form>
更新 2:
感谢BalusC的建议,下面的解决方案应该会更好:
<style type="text/css">
.likeButton .ui-corner-all {
border-radius: 6px 0px 0px 6px !important;
}
</style>
<h:panelGroup styleClass="likeButton">
<p:commandButton />
<h:panelGroup>
最好的问候,
【问题讨论】:
-
尝试最后加载您的 css 文件,例如在
<h:body>中,另外,请确保覆盖ui-button ui-widget ui-state-default ui-corner-all ui-button-text-icon-leftINMO 定义的所需属性,在您的情况下,您最好不要尝试从 js 操作 css -
\:在 MSIE 中不起作用。在您看来,这样的按钮很难完全独一无二。而是使用类名。
标签: css jsf-2 primefaces styling