Forums

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

Home Forums CSS [Solved] nth-last-of-type

  • This topic is empty.
Viewing 15 posts - 1 through 15 (of 16 total)
  • Author
    Posts
  • #171632
    kenpati
    Participant

    Hello. How i can choose only three number with (nth-last-of-type). me need choose only 1,2,3. not 3,2,1. how i can do this?

    #171637
    Paulie_D
    Member

    Your question isn’t quite clear enough.

    Could you try and explain further, perhaps with a Codepen.io or JSfiddle.net example?

    For the example it doesn’t matter how you use CSS to get the result looking the way you want…we can always adapt it from what you show us.

    #171638
    kenpati
    Participant

    i tried to use -n+3 but this mean 3,2,1 not exactly what me need.

    #171639
    Paulie_D
    Member

    Your question still isn’t quite clear enough.

    Could you try and explain further, perhaps with a Codepen.io or JSfiddle.net example?

    #171641
    kenpati
    Participant

    I want to delete margin-bottom only in the last three blocks.

    Example

    #171642
    Paulie_D
    Member

    You mean like this?

    http://codepen.io/Paulie-D/pen/cFbyu

    li:nth-last-of-type(-n+3) {
        margin-bottom: 0;
    }
    
    #171644
    kenpati
    Participant

    watch please my example it’s not solution for last 2,3 blocks. but for one blocks it is working.

    #171646
    kenpati
    Participant

    new Fork Example

    #171647
    kenpati
    Participant

    Paulie_D, hm your example works but why my not working(

    #171648
    Paulie_D
    Member

    Because you are re-using ID’s which is not allowed AND your green block has a different ID.

    You can’t use pseudo-classes like nth-last-of-type on classes or IDs…only elements.

    See: http://codepen.io/Paulie-D/pen/rvLhk

    #171651
    kenpati
    Participant

    Green block must be new contain a another width and another content.
    I don’t no why but i used id with:nth and it working for me.
    but how i can solve this problem?.
    How i can delete this (margin) in last three red blocks?
    don’t using id.

    write for each rule?

    Link

    Please help :)

    #171655
    kenpati
    Participant

    anybody?(

    #171656
    Paulie_D
    Member

    write for each rule?

    Probably, yes.

    I would advise not trying to use these pseudo-classes and just use proper unique IDs and classes.

    It’s still not clear to me what you are trying to do.

    #171661
    kenpati
    Participant

    hm its must be without (margin-bottom).like this one Photobucket.

    Actually in the photo i delete (margin-bottom) directly for each in css. But i think it’s not solution true? I don’t know)

    #171662
    Paulie_D
    Member

    Nope:

    #wrap div:nth-last-of-type(-n+6).block {
      margin-bottom:0;
    }
    

    This did the trick.

    http://codepen.io/Paulie-D/pen/DLJKg

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