Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder Krupski's Avatar
    Join Date
    Dec 2010
    Location
    United States of America
    Posts
    505
    Thanks
    39
    Thanked 47 Times in 46 Posts

    Nested elements CSS - alternative?

    Hi all,

    Currently, I have some CSS to produce alternating background colors for NESTED blockquotes... like this:

    Code:
    blockquote,
    blockquote blockquote blockquote,
    blockquote blockquote blockquote blockquote blockquote {
        background-color: #dddddd;
    }
    
    blockquote blockquote,
    blockquote blockquote blockquote blockquote,
    blockquote blockquote blockquote blockquote blockquote blockquote {
        background-color: #eeeeee;
    }
    ...and it works, but it seems complicated and messy. Is there a simpler, cleaner alternative to get the effect I want?

    Thanks!

    -- Roger
    "Anything that is complex is not useful and anything that is useful is simple. This has been my whole life's motto." -- Mikhail T. Kalashnikov

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,862
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Is there a simpler, cleaner alternative to get the effect I want?
    You may add separate classes on the blockquotes, say calss="even" or class="odd" and use class selectors, like
    Code:
    blockquote.odd{
    
    }
    blockquote.even{
    
    }
    But, why do you need nested blockquotes?
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #3
    Regular Coder Krupski's Avatar
    Join Date
    Dec 2010
    Location
    United States of America
    Posts
    505
    Thanks
    39
    Thanked 47 Times in 46 Posts
    Quote Originally Posted by abduraooft View Post
    You may add separate classes on the blockquotes, say calss="even" or class="odd" and use class selectors, like
    Code:
    blockquote.odd{
    
    }
    blockquote.even{
    
    }
    But, why do you need nested blockquotes?
    Thanks for the reply... but unfortunately I don't have the option to use odd and even.

    As far as nesting quotes, it can happen if a quoted post is quoted again.... like this:

    Quote Originally Posted by Tom
    Quote Originally Posted by Dave
    Quote Originally Posted by Joe
    It looks blue to me
    Sorry I disagree, it's green!
    You are both wrong! It's RED!
    See? There's no way for the quote BBCode to know how many previous quotes are inside it... therefore I can't use even and odd.
    "Anything that is complex is not useful and anything that is useful is simple. This has been my whole life's motto." -- Mikhail T. Kalashnikov


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •