How do I add some spaces between each row of the table. I try this
<p:dataTable styleClass="yourTableClass">
<p:column style="background-color: ##EFF2F9">
//Content here
</p:column>
</p:dataTable>
but it does not work
I used primefaces 2.2.1
The space between two rows in a table can be done using CSS border-spacing and border-collapse property. The border-spacing property is used to set the spaces between cells of a table and border-collapse property is used to specify whether the border of table is collapse or not.
The HTML <table> cellspacing Attribute is used to specify the space between the cells. The cellspacing attribute is set in terms of pixels. Attribute Values: pixels: It sets the space between the cells in terms of pixels.
The space between the table cells is controlled by the CELLSPACING attribute in the TABLE tag. By setting CELLSPACING to zero, you can remove all the space between the cells of your table. This removes all the space between the cells of our table (see Figure 9). Figure 9 Our example with CELLSPACING=0.
Firstly, check your browser make/version: border-spacing
is not supported on IE6/7. Secondly, the border-spacing
only works when the border-collapse
of the table is set to separate
. Likely some PrimeFaces specific stylesheet has set it to collapse
(which is the general UI preferred form of border representation). This way the border-spacing
won't work.
Thus, all with all this should work, including the IE6/7 hack on the last declaration:
.yourTableClass {
border-collapse: separate;
border-spacing: 10px;
*border-collapse: expression('separate', cellSpacing = '10px');
}
with
<p:dataTable styleClass="yourTableClass">
(favour classes over inline styles)
Update: as per the screenshot and the comments, PrimeFaces wraps the generated HTML <table>
inside a <div>
and applies the style
/styleClass
on it instead of on the wrapped <table>
. I did not expect that. In such case, you need the following CSS declaration instead:
.yourTableClass table {
border-collapse: separate;
border-spacing: 10px;
*border-collapse: expression('separate', cellSpacing = '10px');
}
not really sure about primefaces, so am not familiar with which attributes can be used on what bits..
but border-spacing
can't really be reliably used yet as a style.. tables still really need the "old fashioned" cellspacing
attribute
does <p:dataTable cellspacing="10">
work?
change the rule
.yourTableClass {}
to
div div.yourTableClass table {}
if your layout.css
gets called before skin.css
this should make the rule still override it
and you will need the IE hack as mentioned above and maybe you'll need to make it as specific too
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With