Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS When is last-of-type not so?

  • This topic is empty.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #257076
    gulliver
    Participant

    In a WordPress install, a query has last-of-type applied – and which works fine except when paginated.

    My flawed thinking is that in addition to the entry which is genuinely last, pagination causes some preceding entries to also temporarily become last-of-type… as the final item on each page, and hence last-of-type will apply to whichever entry is last on each paginated page.

    But it doesn’t, and is applied only to that which is genuinely last.

    #257078
    Beverleyh
    Participant

    If pagination is built on the fly, on the client-side, it’s likely that ALL the elements are being loaded from the start and just 1-10 and 11-20 etc., are made visible when the appropriate “page” is viewed, so last-of-type is only targeting the true last element regardless of which items are currently seen in the visible “page”.

    There may be an additional class being added to the last item in each “page” via JavaScript – check in the developer console to see if this is that case. Alternatively, try nth-child in CSS https://css-tricks.com/how-nth-child-works/

    #257111
    gulliver
    Participant

    @Beverleyh… thanks.

    With hindsight, ‘only targeting the true last element regardless of which items are currently seen’ seems sensibly correct. I’m now wiser.

    My knowledge of ‘developer console’ is tiny – so this is a good reason to learn more about it.

    ‘nth child’ could be the fix.

    :-)

Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘CSS’ is closed to new topics and replies.