• Resolved tomhodgson

    (@tomhodgson)


    Hi I want to style individual cells, I am using Tablepress to display a colour coded swimming timetable to people but I need to colour code different cells in various colours to denote each session taking place in a grid. I only seem to be able to style the text background colour with the span tags rather than the whole cell which it appears in. Is there another way to do it? Or even have it so the colour of that cell is determined by the content in the cell i.e. the cells would be coloured depending on a specific value in the table cell for instance as follows:

    Value1 – cells always appears blue
    Value2 – cells always appears red
    Value3 – cells always appear green etc etc

    It reads in the documentation like this is possible but I can’t see how to do it, please can you help?

    Many thanks
    Tom

    https://www.ads-software.com/plugins/tablepress/

Viewing 1 replies (of 1 total)
  • Plugin Author TobiasBg

    (@tobiasbg)

    Hi Tom,

    thanks for your question!

    You are right, the <span> solution from the TablePress FAQ can not style the background color of the cell. That’s due to how HTML and CSS work (a child element can not influence the parent element).
    The other way to do this, is also described in the TablePress FAQ, in the same question. It shows some “Custom CSS” code that just needs the row and column numbers for the cells, and can then also change the background color. That’s not very flexible though, especially, if cells can change position in a table, e.g. because new rows are inserted.

    Thus, styling a cell based on the content would remain as an option. Unfortunately, that is not trivial to achieve, as it requires custom PHP code that hooks into TablePress, checks the cell values and adds extra CSS classes that can then be used for styling and coloring.
    I do know how to attack this problem, and already some some code for it, but unfortunately, it’s not really useable yet. Due to time constraints, I don’t have the time to work on this as free support right now, unfortunately. However, if you really need this, I can offer that we try to work something out with some compensation for my time. If that’s on option for you, please send me an email (the address is in the main plugin file “tablepress.php”), so that we can discuss details.
    If that’s not an option for you, I recommend to use the CSS approach from the TablePress FAQ.

    Regards,
    Tobias

Viewing 1 replies (of 1 total)
  • The topic ‘Styling cells’ is closed to new replies.