Hi,
thanks for your post, and sorry for the trouble.
A <span> is a so-called “inline” element, that does not have an actual alignment. The alignment has to be given to the container element instead, in this case the cells in the column. That’s pretty easy wtih some CSS code, so that you shouldn’t even need those extra <span> HTML elements. Instead, just replace
.tablepress .prijs {
with
.tablepress-id-1 .column-2 {
Regards,
Tobias
Is there any hook available to assign a css class to the <td> element like in the code below (taken from WP Table reloaded)?
/* assign all cells with an image icon the 'ico' css class */
function wp_table_reloaded_cell_class_ico( $class, $table_id, $row, $column, $cs, $rs, $cell_content ) {
if ( false !== strpos( $cell_content, '<img' ) )
$class .= ' ico';
return $class;
}
add_filter( 'wp_table_reloaded_cell_css_class', 'wp_table_reloaded_cell_class_ico', 10, 7 );
Corresponding css to achieve centered images in cells:
.wp-table-reloaded tbody tr td.ico {
text-align:center;
}
.wp-table-reloaded tbody tr td img {
vertical-align:middle;
}
Working fine! Thanks a lot!
Geez, that was easy – too easy to guess 😉
Now my problem is solved – and the OP could consider a similar solution: assign the class prijs to the entire cell and take it from there.
e.g.
/* assign all cells with a € character the 'prijs' css class */
function tablepress_cell_class_ico( $cell_class, $table_id, $cell_content, $row_idx, $col_idx, $colspan_row, $rowspan_col ) {
if ( false !== strpos( $cell_content, '€' ) )
$cell_class .= ' prijs';
return $cell_class;
}
add_filter( 'tablepress_cell_css_class', 'tablepress_cell_class_ico', 10, 7 );
Hi,
no problem, you are very welcome! 🙂 Good to hear that this helped!
Yes, Woerdokodo could do that, but in this simple case it would be overkill, I think.
Best wishes,
Tobias
P.S.: In case you haven’t, please rate TablePress here in the plugin directory. Thanks!