0

is it possible to create a background with rows which are different colored?

Here's some Pseudo-Code to illustrate it:

body {
    row-1 {
        height: 250px;
        background-color: red;
    }
    row-2 {
        height: 250px;
        background-color: yellow;
    }
    .
    .
    .
    row-n {
        height: 250px;
        background-color: green;
    }
}

Is it possible to do that in css only?

1
  • "element" :nth-child(odd){background:red} Commented Apr 6, 2016 at 18:23

1 Answer 1

-2

You can use gradient to achieve this. You can use a online css gradient generator. Here is an example.

EDIT: I think I misinterpreted your question. Are you just asking how to give different divs in your body different colors? either give them all distinctive classes so you can style each of them independently, or use :nth-child(x) where you replace x with the div number you want to style (e.g. if you want to style the second div, use :nth-child(2)

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

1 Comment

hmm, don't know if gradient is the proper tool. But thanks I'll lokk into it and no, no html, if possible css only. :)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.