Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

nth-child of CSS3 columns

I'm using CSS3 columns but i want to control each column individually to set different backgrounds to even / odd columns.

I want the result to be as shown in this picture:

Wanted result

The html content:

<div id="content">
    content body text content body text content body text 
    content body text content body text content body text content body text
    content body text content body text content body text content body text
    content body text content body text content body text content body text 
    content body text content body text content body text content body text 
    content body text content body text content body text content body text 
    content body text content body text content body text content body text 
</div>

Css:

#content {
   column-gap:25px;
   column-count:3;
}

I want to use something like:

column:nth-child(even)
{
   background:#0000ff;
}

Can i use CSS3 :nth-child property? or can i use any javascript solution to get selector of any individual column?

Please give your suggested solutions.

Thank you in advance

like image 471
semsem Avatar asked Nov 01 '22 02:11

semsem


1 Answers

Add absolute positioned background blocks for styling..

Something like this:

#bg1 {
  position: absolute; 
  width:30%;
  height:100%;
  background-color:green;
  z-index:-1;
}

Fiddle

like image 158
vp_arth Avatar answered Nov 12 '22 16:11

vp_arth