WordPress.org

Ready to get started?Download WordPress

Forums

Montezuma
[resolved] Suppressing table formatting (3 posts)

  1. rjrobinson
    Member
    Posted 9 months ago #

    I like the Montezuma table formatting (alternating row colours, etc.) but occasionally I'd like to suppress it. Is this possible?

  2. CrouchingBruin
    Member
    Posted 9 months ago #

    Sure. Every other row in a table will have the class alternate assigned to it. The CSS rule that controls the background color of such rows is this:

    .hentry table tr.alternate td, .comment-text table tr.alternate td {
    background: #f7f7f7;
    }

    So there's a couple of approaches you can take:

    Let's say you want to suppress the alternate colors on a particular page (or post, the instructions are the same). Here's what I would do:

    Do either a "view source" or inspect the page using a web debugging tool like Firebug or Chrome Developer Tools. Look at the body tag. Each page and post will have a unique numeric ID assigned to it, and that ID will be assigned to the body element as a class which looks like page-id-49 or postid-247. So to suppress the alternate colors for the tables on that page or post, just add a CSS rule to the end of your virtual various.css file with the body class at the beginning of the selector:

    .page-id-49 .hentry table tr.alternate td {
       background: none;
    }

    The above example will suppress the alternate color for all tables on the page with the ID of 49 without affecting the tables on any other page or post.

    You can also create a class that you will assign to tables that you don't want to alternate colors, like no_alt, and add a CSS rule to suppress the alternating colors for those tables that have that class assigned to them.

    You would add this CSS rule at the end of your various.css file. Note that the selector is the same as the default, but with the class no_alt added to the table element:

    .hentry table.no_alt tr.alternate td {
       background: none;
    }

    Then when you create a table, give it a class of no_alt:

    <table class="no_alt" border="1" cellspacing="0" cellpadding="0">
    ...
    </table>

    Then that table will not show alternating colors for the rows.

  3. rjrobinson
    Member
    Posted 9 months ago #

    Excellent - thanks for helping me again!

Reply

You must log in to post.

About this Theme

About this Topic