Forums

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

Home Forums CSS [Solved] [class*='grid-']:last-of-type

  • This topic is empty.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #150282
    sadunaresh
    Participant

    codepen

    in the above pen

    SECTION and ASIDE are children of a DIV, but , “[class*=’grid-‘]:last-of-type ” applies to both of them.

    please explain this behaviour..

    #150292
    Paulie_D
    Member

    Perhaps you are thinking of :last-child?

    http://codepen.io/anon/pen/bpqeK

    #150304
    Paulie_D
    Member

    Wait…no, I think I have cracked it….you didn’t specify the element type that the last of type was to apply to.

    If you make it div[class*='grid-']:last-of-type I think it works.

    http://codepen.io/anon/pen/fvome

    What you had before was (I think) , effectively last-of-class and that doesn’t exist.

    #150440
    sadunaresh
    Participant

    @paulie…

    I have my answer in your reply…

    I wanted the last of type to apply only for last child(in a parent with class name starting with grid-) with class name that starts with grid-.

    It works fine in following cases

       <div class="grid-"></div>
       <div class="grid-"></div>
    

    or

    <div>
    </div>
    

    but it doesn’t work for following

    <div>
    </div>
    

    as children are of different element types… yes by last-of -type it is targeting last child of each element type with [class*=’grid-‘], with in a container….

    thank you, very much…

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