0

my problem is simple. I've put my code on this fiddle: http://jsfiddle.net/G79X9/61/

.historyContainer{
    margin-top: 45px;
    width: 856px;
    margin: 29px auto;
    }
    .depositContainer :nth-child(even)
    {
        background-color: green;
    }
    .depositContainer :nth-child(even)
    {
        background-color: red;
    }
    .withdrawContainer :nth-child(even)
    {
        background-color: red;
    }
    .withdrawContainer :nth-child(even)
    {
        background-color: green;
    }
    .offerHistory1{
        width: 50%;
        float: left;
        text-align: center;
        background-color: #cdc;
    }
    .offerHistory2{
        width: 50%;
        float: left;
        text-align: center;
        background-color: #dcd;
    }
    .depositHistory{
        width: 50%;
        float: left;
    }
    .withdrawHistory{
        width: 50%;
        float: right;
    }

I just want the divs background to be "stripped"(one with one color and the other with another color). I thought this should work but it isn't.

1
  • In JSFiddle you can tidy up your code! It's right from the save button. Commented Dec 29, 2015 at 1:21

2 Answers 2

3

So like this?

<div class="historyContainer">
  <div class="offerHistory1">Deposit</div>
  <div class="offerHistory2">Withdraw</div>
  <div class="depositHistory">
    <div class="depositContainer"><b>ID: 25 - Status: </b>Forbiden: Trade hold</div>
    <div class="depositContainer"><b>ID: 24 - Status: </b>Forbiden: Trade hold</div>
  </div>
  <div class="withdrawHistory">
    <div class="withdrawContainer"><b>ID: 38 - Status: </b>coins refunded</div>
  </div>
</div>

CSS code...

.historyContainer{
    margin-top: 45px;
    width: 856px;
    margin: 29px auto;
}
.depositContainer:nth-child(even)
{
    background-color: green;
}
.depositContainer:nth-child(odd)
{
    background-color: red;
}
.withdrawContainer:nth-child(even)
{
    background-color: red;
}
.withdrawContainer:nth-child(odd)
{
    background-color: green;
}
.offerHistory1{
    width: 50%;
    float: left;
    text-align: center;
    background-color: #cdc;
}
.offerHistory2{
    width: 50%;
    float: left;
    text-align: center;
    background-color: #dcd;
}
.depositHistory{
    width: 50%;
    float: left;
}
.withdrawHistory{
    width: 50%;
    float: right;
}

http://jsfiddle.net/jonathanzuniga/7kp131d9/

Sign up to request clarification or add additional context in comments.

2 Comments

@MarcielFonseca You need to add even or odd. Not all even.
@MarcielFonseca I just removed the blank space between the classes and the pseudo selectors and replace the second :nth-child(even) with :nth-child(odd).
3

you have two mistakes in your code:

1.) Don't leave spaces before pseudo-classes: Not .depositContainer :nth-child(even), but .depositContainer:nth-child(even)

2.) You have to swap between "odd" and "even" in the parenthesis after your pseudo-classes

1 Comment

Wow, how could I not notice that? Thank You!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.