I currently have 10 items that I am iterating through to display each one. I would like the opacity of the last element to be the lowest and the first element to be the highest. While I am familiar with using :first
and :last
in tailwind-css
, I am curious if there is a way to target, for example, the 8th or 9th element using tailwind-css
.
Below is the return statement from a component:
{[0,1,2,3,4,5,6,7,8,9].map((item) => (
<section
key={item}
className='last:opacity-20 flex justify-between items-center text-slate-600 bg-white shadow-sm p-5 rounded-xl my-4 cursor-pointer dark:bg-black dark:text-slate-400'
>
<div className='flex gap-3 items-center'>
<div className='rounded-full w-8 h-8 bg-slate-200'></div>
<p className='w-44 h-4 bg-slate-100'></p>
</div>
<p className='w-16 h-4 bg-slate-100'></p>
</section>
))}
My goal is to decrease the opacity
as you move downwards the list, starting from the first item.