I recently started to give tailwind.css a try in my Nuxt project. so I needed to use :not(:last-child)
pseudo-elements but I didn't find how.
<ul>
<li
v-for="(item, index) in items"
:key="`item-${index}`"
class="border-solid border-b border-black"
>
Item
</li>
</ul>
I want to add a border-bottom to all of the <li>
except the last one.
I know Tailwind has first & last pseudo-class variant but I can't use them with :not()
Use hidden to set an element to display: none and remove it from the page layout (compare with . invisible from the visibility documentation).
Use invisible to hide an element, but still maintain its place in the DOM, affecting the layout of other elements (compare with . hidden from the display documentation).
In Tailwind CSS, the equivalents to the :first-child and :last-child pseudo-classes of CSS are the first and last modifiers, respectively. You can use them to style the first/last child of its parent.
The answer is in the link to last
in the docs, that you shared.
Just add last:border-b-0
to all list items, and it will remove the border-bottom
if it is the last-child
.
<ul>
<li
v-for="(item, index) in items"
:key="`item-${index}`"
class="border-solid border-b border-black last:border-b-0"
>
Item
</li>
</ul>
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