Changing CSS for last
  • 前端 未结 10 1560
    暗喜
    暗喜 2020-11-30 22:30

    I am wondering if there is some way to change a CSS attribute for the last li in a list using CSS. I have looked into using :last-child, but this

    10条回答
    •  旧时难觅i
      2020-11-30 23:26

      I usually combine CSS and JavaScript approaches, so that it works without JavaScript in all browsers but IE6/7, and in IE6/7 with JavaScript on (but not off), since they does not support the :last-child pseudo-class.

      $("li:last-child").addClass("last-child");
      
      li:last-child,li.last-child{ /* ... */ }
      

    提交回复
    热议问题