• Skip to main content
  • Skip to forum navigation

StudioPress

  • Shop for Themes
  • My StudioPress

Forum navigation

  • Home
  • General Genesis Discussions
  • StudioPress Themes
  • Genesis Blocks
    • Genesis Blocks
    • Genesis Custom Blocks
  • Retired Themes
  • FAQs
  • Forum Rules
  • Internationalization and Translations
  • Forum Bugs and Suggestions
  • Forum Log In

Are You Using The WordPress Block Editor?

Genesis now offers plugins that help you build better sites faster with the WordPress block editor (Gutenberg). Try the feature-rich free versions of each plugin for yourself!

Genesis Blocks Genesis Custom Blocks

Rows With Alternating Colors

Welcome!

These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.

Log In
Register Lost Password

Community Forums › Forums › Archived Forums › General Discussion › Rows With Alternating Colors

This topic is: not resolved

Tagged: nth-child css

  • This topic has 5 replies, 2 voices, and was last updated 10 years, 3 months ago by Tom.
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • November 12, 2015 at 1:26 pm #170899
    dfree99
    Member

    I'm trying to duplicate this format in my post content:

    http://www.bbb.org/dallas/accredited-business-directory/air-conditioning-contractors-and-systems

    In particular, I want it to be full rows (100%) that are responsive rows with colored backgrounds. But without using html tables.

    How can I do this?

    November 12, 2015 at 2:02 pm #170905
    Tom
    Participant

    How do you identify the colour each post should be? (Your example is not alternating, nor does it display a pattern.)
    How many colours?
    What theme are you using?


    Choose your next site design from over 350 Genesis themes.
    [ Follow me: Twitter ] [ Follow Themes: Twitter ] [ My Favourite Webhost ]

    November 12, 2015 at 2:06 pm #170906
    dfree99
    Member

    I'm using education pro theme.

    I'm not particular about the color. It can be alternating. It doesn't really matter, I just would like some differentiation between rows.

    November 12, 2015 at 2:15 pm #170907
    Tom
    Participant

    Simple CSS can do this for you:

    .post:nth-child(1n) {       /* odd posts are this colour */
      background: chocolate;
    }
    
    .post:nth-child(2n) {        /* even posts are this colour */
      background: cornflowerblue;
    }

    Change the selector if you want to attach the colour differently.
    See more about nth-child: https://css-tricks.com/how-nth-child-works/


    Choose your next site design from over 350 Genesis themes.
    [ Follow me: Twitter ] [ Follow Themes: Twitter ] [ My Favourite Webhost ]

    November 12, 2015 at 2:21 pm #170908
    dfree99
    Member

    This looks great, but it appears to be formatting the rows to link to other full posts.

    I am actually trying to display content inline, all relating to 1 post. These are not excerpts from a full post. This is all content detail for this one post.

    In other words, I will be entering information for 3 -5 businesses, but the data will all be entered into 1 post.

    November 12, 2015 at 8:17 pm #170955
    Tom
    Participant

    So, within a given post, you want different sections to have different background colours?

    Simply add a CSS class per business as an inline style in the post markup and use those classes to style the colours. You could get programmatic about this, building custom post sections and fields, if you want.


    Choose your next site design from over 350 Genesis themes.
    [ Follow me: Twitter ] [ Follow Themes: Twitter ] [ My Favourite Webhost ]

  • Author
    Posts
Viewing 6 posts - 1 through 6 (of 6 total)
  • The forum ‘General Discussion’ is closed to new topics and replies.

CTA

Ready to get started? Create a site or shop for themes.

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2026 WPEngine, Inc.

Products
  • Create a Site with WP Engine
  • Shop for Themes
  • Theme Features
  • Get Started
  • Showcase
Company
  • Brand Assets
  • Terms of Service
  • Accptable Usse Policy
  • Privacy Policy
  • Refund Policy
  • Contact Us
Community
  • Find Developers
  • Forums
  • Facebook Group
  • #GenesisWP
  • Showcase
Resources
  • StudioPress Blog
  • Help & Documentation
  • FAQs
  • Code Snippets
  • Affiliates
Connect
  • StudioPress Live
  • StudioPress FM
  • Facebook
  • Twitter
  • Dribbble