I have a definition list as follows:
<dt>Term1</dt>
<dd>Definition1</dd>
<dt>Term2</dt>
<dd>Definition2</dd>
<dt>Term3</dt>
<dd>Definition3</dd>
<dt>Term4</dt>
<dd>Definition4</dd>
I would like to use CSS to give every odd row a different background-color using nth-child(odd) but this does not work with the structure of the definition list unless I can group each dt and dd together in a wrapper.
Does anybody know of a way I could achieve this alternating background effect?
Thanks
EDIT** I should have pointed out that I need the Term and the Definition to appear side by side. So each pair of DT & DD should have alternating colors.
Right-click the data row as shown in the below screenshot, click F4 or properties window in the View menu. When selecting this, you will see the BackgroundColor option. By default, it is No Color, which means that there is no color for the background and use can select any colors.
This works for me:
dt, dd {
background-color: blue;
}
dt:nth-child(4n+1), dt:nth-child(4n+1) + dd {
background-color: red;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With