If the content of your `<pre>` is stored in a separate tiddler or field, 
you can force the creation of child `<div>` elements, so that 
`nth-child(even)` can be applied successfully.

Give this a try:
```
\define nthchild(txt,bg:"lightgray")
\whitespace trim
<style> .myClass div:nth-child(even) { background:$bg$; } </style>
<pre class="myClass">
   <$list filter="[<__txt__>splitregexp[\n]]" variable="line">
       <div><$text text=<<line>>/></div>
   </$list>
</pre>
\end

<$macrocall $name="nthchild" txt={{test}} bg="powderblue"/>
```

where the text content is stored in a tiddler named "test".

-e
On Sunday, February 20, 2022 at 4:46:32 PM UTC-8 [email protected] 
wrote:

> Ah, well- that's a bummer haha
>
> Thank you!
> On Sunday, February 20, 2022 at 7:30:21 PM UTC-5 Eric Shulman wrote:
>
>> Although HTML `<pre>` elements can display multiple lines of text, each 
>> line is not a separate child element.
>> Thus, a CSS rule such as `nth-child(even)` doesn't have any effect within 
>> the `<pre>` element.
>>
>> -e
>> On Sunday, February 20, 2022 at 4:13:04 PM UTC-8 [email protected] 
>> wrote:
>>
>>> Hello all, title says it all.
>>>
>>> When trying to apply nth-child(even) to use a background color for each 
>>> line when using <pre> in my tiddlers, it doesn't seem to work, and I'm not 
>>> entirely sure whats causing this.
>>>
>>> Any suggestions?
>>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/a6d7384e-bca3-4dae-be45-7f982d6b70b0n%40googlegroups.com.

Reply via email to