I was just wondering how to get such a design when everything will be dynamic? I mean, there should be only one class that can be used to get the background color, depending on whether the block is odd or even. I hope my requirements are clear: the background color changes with an odd or even number of lines.
You are looking for alternating lines. This is achieved by adding another class to each other row.
The textbooks have a lot about how to do this.
CSS3 also provides a new way to do this without adding classes:
tr:nth-child(odd) { background-color:#eee; } tr:nth-child(even) { background-color:#fff; }
, CSS.
tr:nth-child(2n+1) {YOURSTYLEINHERE} or tr:nth-child(odd) {YOURSTYLEINHERE}
Add a second css class for the striped string. Assuming the default bg color is dark gray, the second class will look like this:
.altRow {background-color: white! important; }
If you do not want to encode the logical server side for applying the second class, you can use the JQuery Odd Selector . But about the same as you, you will end up in striped stripes without the manual application of the second class.
What you want is modular division
if(rowNum % 2 == 0) {class="even"} else {class="odd"}
OR, if you are using CSS3, you can do it like this:
tr:nth-child(even) {background: #CCC} tr:nth-child(odd) {background: #FFF}
Source: https://habr.com/ru/post/1786928/More articles:ΠΊΠ°ΠΊ Ρ ΠΌΠΎΠ³Ρ ΠΏΠΎΠΊΠ°Π·Π°ΡΡ ΠΈΠ·ΠΎΠ±ΡΠ°ΠΆΠ΅Π½ΠΈΠ΅ Π² Π°Π½Π½ΠΎΡΠ°ΡΠΈΠΈ Π½Π° ΠΊΠ°ΡΡΡ? - iphoneΡΡΠΎ ΡΠ²Π»ΡΠ΅ΡΡΡ ΠΏΡΠ°Π²ΠΈΠ»ΡΠ½ΡΠΌ ΡΠΈΠ½ΡΠ°ΠΊΡΠΈΡΠΎΠΌ xml Π΄Π»Ρ ΠΎΠΏΡΠ΅Π΄Π΅Π»Π΅Π½ΠΈΡ ΡΠ»Π΅ΠΌΠ΅Π½ΡΠ° ΡΠΎΡΠΌΡ Π² ΡΠΎΡΠΌΠ΅ zend - xmlError generating .zip files in prod (Rails 3) - ruby ββ| fooobar.comhow can I make a method call from a specific versioned jar when several versions are present - javaΠΠ°ΠΊΠΎΠ² ΠΏΡΠ°Π²ΠΈΠ»ΡΠ½ΡΠΉ ΡΠΈΠ½ΡΠ°ΠΊΡΠΈΡ ΠΎΠΏΠΈΡΠ°Π½ΠΈΡ ΡΠ»Π΅ΠΌΠ΅Π½ΡΠ° ΡΠΎΡΠΌΡ Π΄Π»Ρ Zend_Form Ρ ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°Π½ΠΈΠ΅ΠΌ XML Π² ΠΊΠ°ΡΠ΅ΡΡΠ²Π΅ ΠΊΠΎΠ½ΡΠΈΠ³ΡΡΠ°ΡΠΈΠΈ? - xmlΠΠ°ΠΊ Ρ ΠΌΠΎΠ³Ρ ΡΠΎΡΡΠΈΡΠΎΠ²Π°ΡΡ ΡΠΈΡΠ»Π° ΡΠ°ΠΊ, ΠΊΠ°ΠΊ Π΅ΡΠ»ΠΈ Π±Ρ ΠΎΠ½ΠΈ Π±ΡΠ»ΠΈ ΡΠ»ΠΎΠ²Π°ΠΌΠΈ? - sortingJava Interfaces - Parametric Polymorphism - javaOptional ByRef - Wrong in VB.NET? - .netProblems managing WebBrowser (coding and XHTML pages) - c #https://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1786933/how-do-i-allow-mobile-users-to-bypass-the-redirect&usg=ALkJrhgL0fcx-z8B4mgqnXHHIikGRTjMVQAll Articles