【问题标题】:last-child is not working in IE8 browserlast-child 在 IE8 浏览器中不起作用
【发布时间】:2014-11-28 18:32:22
【问题描述】:

CSS : last-child 在 IE8 浏览器中无法使用此标记的任何替代解决方案。

我尝试使用 :last-of-type,但它也不起作用。

谁能帮我解决这个问题?

谢谢 Jagadeesh.N

【问题讨论】:

  • 也许你可以使用 jQuery

标签: css internet-explorer internet-explorer-8


【解决方案1】:

:first-child 仅在 IE8 中受支持,但很抱歉,:last-child 在 IE8 中不受支持。

为简单起见,只需为该 div 定义类名并应用 css


使用 jQuery 的解决方案:

$('*').last().addClass('last-child');

或者,

$('*:last-child').addClass('last-child');/*use it with care*/

所以现在您可以简单地将div.last-child 用作样式表中的选择器。

【讨论】:

    【解决方案2】:

    IE8不支持:last-child所以,你可以用这个方法:

    您最好的选择是显式添加一个 last-child(或类似)类 该项目,并应用 li.last-child 代替。

    【讨论】:

      【解决方案3】:

      你总是可以为此加载一个 polyfill:

      <!--[if (gte IE 6)&(lte IE 8)]>
        <script type="text/javascript" src="selectivizr.js"></script>
      <![endif]-->
      

      这是链接:http://selectivizr.com/

      【讨论】:

        猜你喜欢
        • 2013-09-26
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-12-17
        • 2012-05-26
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多