• Resolved burrorock

    (@burrorock)


    Hi, all-

    Using TablePress, I am trying to set up a table to display a series of data entries consisting of 2 rows each.

    I am trying to do the following:
    a) Bold the text on the ODD rows.
    b) Add a little space to the bottom of each EVEN row.
    c) Create a row span on ODD rows to accommodate a longer entry.

    Adding this code to my table works to bold the ODD rows:

    .tablepress-id-1 .row-1,
    .row-3,
    .row-5 {
    	font-weight: bold;
    }

    Adding this code to my table turns the borders off and affects the spacing on ALL rows (not just EVEN rows):

    .tablepress-id-1, 
    .tablepress-id-1 tr,
    .tablepress-id-1 tbody td,
    .tablepress-id-1 thead th,
    .tablepress-id-1 tfoot th {
    	border: none;
    	padding-top: 18px;
    }

    The code listed above is all based on examples from the TablePress website.

    So, to my questions:
    1. Is a table the right approach for what I want to do? I’m envisioning having up to 2 or 3 thousand entries in my table.

    2. Is there a better way to specify all the ODD rows than what I am doing in my first example, specifying each ODD row individually? Is there a reserved word that will let me specify all ODD rows with only one line?

    3. How can I adjust the padding or margin on just the EVEN rows? I tried adjusting the padding & margins by adding the code from my second example to my first example, but it doesn’t work. I also tried specifying row numbers in my second example, using the same format shown in my first example, but it doesn’t work.

    I’m guessing there is a simple solution, but it’s beyond my ken.

    Best,

    Chris

    • This topic was modified 6 years, 1 month ago by Jan Dembowski. Reason: Moved to Fixing WordPress, this is not an Developing with WordPress topic
Viewing 11 replies - 1 through 11 (of 11 total)
  • Moderator Jan Dembowski

    (@jdembowski)

    Forum Moderator and Brute Squad

    Moved to Fixing WordPress, this is not an Developing with WordPress topic.

    Please ask plugin specific questions in that plugin’s dedicated sub-forum instead.

    https://ww.wp.xz.cn/support/plugin/tablepress/#new-post

    1. Tables are specifically for displaying data that repeats. But do you really want 1000 in a single table? There are plugins to add a script called sorttable, so that the data can be sorted by columns.

    2. Yes, there is a better way. It is called :nth-of-type. See https://developer.mozilla.org/en-US/docs/Web/CSS/:nth-of-type and this page helps you test your CSS http://lea.verou.me/demos/nth.html

    3. You often can’t do much about height or width or margins on tables. But using padding on the td or any tags that are in the td should work.

    Hi,

    thanks for your post, and sorry for the trouble.

    As Joy already mentioned, using :nth-of-type is a possibility. TablePress also has .odd and .even CSS classes. With that, you could write your code as

    .tablepress-id-1 .odd td {
    	font-weight: bold;
    }

    To help more, it would be good to see the page with the table. Can you please post a link to the page with the table where this problem happens, so that I can take a direct look? Thanks!

    Regards,
    Tobias

    Thread Starter burrorock

    (@burrorock)

    Hi, @joyously & @tobiasbg

    Thank you for your replies.

    The table can viewed here: Table.

    I am close to achieving my goal, the ODD rows are bolded, and I’ve gotten rid of the borders, but there are three things I would still like to achieve:
    1. Adjust the margins/padding/spacing to reduce the spacing between the ODD/EVEN rows & increase the spacing between EVEN/ODD rows.

    2. Understand how to use the .odd and .even CSS classes.

    3. Turn the borders back on (I’m going to leave them off, but when I remove border: none;, I see only a line between rows rather than borders everywhere.)

    Thank you for your help!

    Best,

    Chris

    • This reply was modified 6 years, 1 month ago by burrorock. Reason: Fix typos

    Hi Chris,

    unfortunately, your link is not working for me, it’s only showing an “Under construction” error.

    My suggestion here is to play around with this more in the Developer Tools of your browser. These let you test CSS code live in the page.

    Regards,
    Tobias

    Thread Starter burrorock

    (@burrorock)

    @tobiasbg – Can you try it again? It looks like I forgot to publish the page!

    Hi,

    no, not working yet. It looks like you have activated a plugin for this.

    Regards,
    Tobias

    Thread Starter burrorock

    (@burrorock)

    @tobiasbg – Hi, sorry to be a pain. Can you try it again?

    Hi,

    no I can see the table 🙂

    Please try replacing your current “Custom CSS” with this:

    .tablepress-id-1 tr:nth-child(odd) td {
    	font-weight: bold;
    	border-top: none;
    }
    
    .tablepress-id-1 tr:nth-child(even) td {
    	padding-bottom: 50px;
    }

    Is that what you are looking for? Note that borders everywhere will not really work, as also that white space between the EVEN/ODD rows would have that border.

    Regards,
    Tobias

    Thread Starter burrorock

    (@burrorock)

    That worked beautifully, @tobiasbg

    Many thanks to you & @joyously for sharing your knowledge, it is greatly appreciated!

    TablePress is very useful and I will be sending you some money for a couple of extensions, once I figure out exactly which ones I need.

    Thanks again!

    Best,

    Chris

    Hi,

    no problem, you are very welcome! 🙂 Good to hear that this helped!
    And thanks for wanting to donate, I really appreciate it!

    Best wishes,
    Tobias

    P.S.: In case you haven’t, please rate TablePress here in the plugin directory. Thanks!

Viewing 11 replies - 1 through 11 (of 11 total)

The topic ‘Adding CSS to TablePress to Modify Text Attributes’ is closed to new replies.