Support » Plugin: TablePress » Centering text in select columns

  • Resolved macaw9

    (@macaw9)


    Hi Tobias,

    I’ve put TablePress to good use, having created over 200 tables for a new section in the works for our website. Here’s an example:

    1977 Seattle Seahawks

    I’ve been using the <center></center> tags on text items in select columns on the shorter tables; but the team roster pages have a lot of rows. I would like to use some css to center the text in selected columns, for example from the above page link: No., Age, Position, G, GS, and Years. Going through the support threads I found an entry with this snippet:

    .tablepress-id-12 .column-1 {
    vertical-align: middle;
    }

    So checking to see if this is close to what I need, and if so, can it be modified to handle all the Team Roster tables at once, instead of having to use id-12, id-13, etc., for each Roster table? And how would this be extended for selected columns? Something like:

    .tablepress-id-12 .column-1 {
    vertical-align: middle;
    .column-4 {
    vertical-align: middle;
    .column-5 {
    vertical-align: middle;
    }

    etc.?

    The .csv spreadsheet upload option sure works great to get the team rosters up.

    Thanks!

    https://wordpress.org/plugins/tablepress/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    thanks for your question, and sorry for the trouble.

    I’ll start with your last question: To have the code apply to multiple columns of the same table, the correct structure is

    .tablepress-id-12 .column-1,
    .tablepress-id-12 .column-4,
    .tablepress-id-12 .column-5 {
      vertical-align: middle;
    }

    i.e. a comma-separated list of the full selectors.

    To have this apply to multiple tables of the same structure, I suggest to use “Extra CSS classes”. For example, you could give such a class with the name “tablepress-roster-table” (or whatever you want) to each table (in the “Extra CSS classes” field on the table’s “Edit” screen). Then, you could use that Extra CSS class in your CSS code, like

    .tablepress-roster-table .column-1 {
      vertical-align: middle;
    }

    and so on. Each table that has this “Extra CSS class” will automatically use that code, so that will have shorter CSS code.

    Now, as you mention <center> HTML tags, I assume that you actually want to use

    text-align: center;

    instead of

    vertical-align: middle;

    as your CSS command. The first one will center horizontally, while the second one will center vertically.

    Regards,
    Tobias

    macaw9

    (@macaw9)

    Thanks Tobias, that did the trick! Here’s what I did:

    .tablepress-roster-table .column-1,
    .tablepress-roster-table .column-4,
    .tablepress-roster-table .column-5,
    .tablepress-roster-table .column-6,
    .tablepress-roster-table .column-7,
    .tablepress-roster-table .column-9 {
    text-align: center;
    }

    You’re the man!

    Hi @macaw9,

    I am a novice in wordpress. I have gone through your page link http://www.seahawkslegends.com/1977-seattle-seahawks/ and found the data table colorfully designed, specially the alternative row color of grey and white, also the beautiful header and the mouse hovering color matching with menu color. It is really excellent.
    How have you done this? May be with custom CSS code.
    What is the CSS code for changing color of rows?
    Where can I find CSS Code for manipulating a table?
    Will you guide me , please?

    Regards,
    Fazlul Haque

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi macaw9,

    good to hear that this helped!

    @mfhaq77:
    Yes, this is all CSS code. For some examples, please take a look at the TablePress FAQ at https://tablepress.org/faq/

    Regards,
    Tobias

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Centering text in select columns’ is closed to new replies.