我正在使用 PrimeFaces dataTable
组件,如下所示:
<p:dataTable
value="#{bean.objects}" var="item"
paginator="true"
rows="10"
paginatorTemplate="{FirstPageLink}
{PreviousPageLink}
{PageLinks}
{NextPageLink}
{LastPageLink}
{RowsPerPageDropdown}"
rowsPerPageTemplate="5,10,15,20,30,50,100"
styleClass="shorterDropdown">
<p:column>...
</>
</>
paginatorTemplate
添加了 RowsPerPageDropdown
。我的目标是通过 css 文件中的 shorterDropdown
类更改此下拉菜单宽度,但它不起作用。这是 CSS 代码:
select.shorterDropdown
{
width:45px;
}
如何通过 CSS 更改此下拉菜单的宽度?
最佳答案
要覆盖 Primefaces 的默认样式,请编辑您的 CSS 修改(使用开发者工具,找到 css 选择器(类名 ....))然后添加“importante!”像这样的 CSS 规则 style="background: red !important;"
有关css优先级的更多信息:(调用顺序:最后调用的是应用的)在同一级别时:
重要的! > #id > .class > html 标签
希望对您有所帮助。
关于css - p :dataTable style change?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21262414/