【发布时间】:2014-11-28 18:32:22
【问题描述】:
CSS : last-child 在 IE8 浏览器中无法使用此标记的任何替代解决方案。
我尝试使用 :last-of-type,但它也不起作用。
谁能帮我解决这个问题?
谢谢 Jagadeesh.N
【问题讨论】:
-
也许你可以使用 jQuery
标签: css internet-explorer internet-explorer-8
CSS : last-child 在 IE8 浏览器中无法使用此标记的任何替代解决方案。
我尝试使用 :last-of-type,但它也不起作用。
谁能帮我解决这个问题?
谢谢 Jagadeesh.N
【问题讨论】:
标签: css internet-explorer internet-explorer-8
: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 用作样式表中的选择器。
【讨论】:
IE8不支持:last-child所以,你可以用这个方法:
您最好的选择是显式添加一个 last-child(或类似)类 该项目,并应用 li.last-child 代替。
【讨论】:
你总是可以为此加载一个 polyfill:
<!--[if (gte IE 6)&(lte IE 8)]>
<script type="text/javascript" src="selectivizr.js"></script>
<![endif]-->
【讨论】: