statamic-classify icon indicating copy to clipboard operation
statamic-classify copied to clipboard

Allow for :first-child

Open michaelmannucci opened this issue 3 years ago • 4 comments

It would be great to be able to do something like:

h2:first-child' => 'mt-0',

So that the first element on the page has no top-margin, but does elsewhere. I tried it but it doesn't seem to work.

michaelmannucci avatar Jan 19 '22 16:01 michaelmannucci

Oh yes this would be a good feature. But it is only necessary if you use Tailwind CSS,isn't it? In plain CSS you can define it by a selector.

flemming-pr avatar Jan 24 '22 13:01 flemming-pr

Would be awesome to do it in Tailwind though ;)

michaelmannucci avatar Jan 28 '22 17:01 michaelmannucci

@michaelmannucci I think that should work fine already. I have used the pseudo classes from TailwindCSS like this.

classify.php

<?php

return [

    /*
    |--------------------------------------------------------------------------
    | Stylesets
    |--------------------------------------------------------------------------
    |
    | Here you can define different style collections.
    | To add a new styleset you have to add a new array like the 'blog' array.
    |
    */

    'default' => [
        'h2' => 'font-bold text-5xl first:text-red-900 last:text-sky-600',
    ],
];

grafik

Or dou I understand you wish wrong?

flemming-pr avatar Feb 09 '22 09:02 flemming-pr

I believe that would style the first H2 on the page, regardless if it's the first-child of the div... so if you wanted to remove top-margin for the first H2, it wouldn't work if the first element isn't an H2.

Also, your example doesn't seem to work for me... lol

michaelmannucci avatar Feb 22 '22 00:02 michaelmannucci

Hi @michaelmannucci,

you should be able to use the first or first-of-type utility from tailwindcss to accomplish your goal.

lakkes-ra avatar Dec 30 '24 10:12 lakkes-ra