2014-04-06 15 views
5

Sto usando CSS3 columns ma voglio controllare ciascuna colonna singolarmente per impostare sfondi diversi su colonne pari/dispari.nth-child di colonne CSS3

Voglio che il risultato da come mostrato in questa immagine:

Wanted result

il contenuto HTML:

<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; 
} 

voglio usare qualcosa del tipo:

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

Posso usare CSS3 :nth-child proprietà? o posso usare qualsiasi soluzione javascript per ottenere il selettore di ogni singola colonna?

Si prega di dare le vostre soluzioni suggerite.

Grazie in anticipo

+1

Io non credo che ci sia un modo per farlo Questo. – Scimonster

risposta

2

Aggiungi background blocchi posizionati assoluti per lo styling ..

Qualcosa di simile a questo:

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

Fiddle

+0

Sapevi che altri motori di rendering oltre a WebKit supportano le colonne CSS3? – FelipeAls

+0

@FelipeAls, con prefissi (-moz- per FF) –

+0

http://www.w3schools.com/css/css3_multiple_columns.asp –