CSS: Last element on line

前端 未结 6 813
轮回少年
轮回少年 2020-12-15 16:15

I\'ve got an unordered [inline] list of links that wraps across two lines:
\"links



        
6条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-15 16:44

    Based on the accepted answer in coffee:

    do lastinline = ->
            $('[lastinline]').each ->
                $parent = $ @
                lastElement = false
                $parent.find('> *').each ->
                    $child = $ @
                    if lastElement && lastElement.offset().top != $child.offset().top
                        lastElement.addClass "last-in-line"
                    lastElement = $child
    
                .last().addClass "last-in-line"
    
    $(window).on 'resize', lastinline
    

提交回复
热议问题