简体   繁体   English

使IE8中的第一胎和最后胎工作

[英]Make first-child and last-child work in IE8

In my project, I am trying to make the below css work in IE8 using selectivizr 在我的项目中,我正在尝试使用selectivizr在IE8中使以下CSS工作

thead>tr:first-child>th:last-child {
    color: red;
}
tbody>tr:first-child>td:last-child {
    color: red;
}

As described in Selectivizr website, I added the below code in " External Resources " of JSFiddle . Selectivizr网站中所述,我在JSFiddle的外部资源 ”中添加了以下代码。

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
<!--[if (gte IE 6)&(lte IE 8)]>
  <script type="text/javascript" src="https://github.com/keithclark/selectivizr/blob/master/selectivizr.js"></script>
  <noscript><link rel="stylesheet" href="[fallback css]" /></noscript>
<![endif]-->

Still I can't make first-child and last-child pseudo selectors work in IE8. 我仍然无法在IE8中使用first-childlast-child伪选择器。

I am switching all the versions of IE into IE8 using the following code. 我使用以下代码将IE的所有版本切换为IE8。 ( just for information ). 仅供参考 )。

<meta http-equiv="X-UA-Compatible" content="IE=8" >

This selectors does not support in IE8, so you can assign id or special class to first and last elements. IE8不支持此选择器,因此您可以将id或特殊类分配给first和last元素。 For example: 例如:

<tr class="thisSection">
     <td class="customClass firstTD">1</td>
     <td class="customClass">2</td>
     <td class="customClass">3</td>
     <td class="customClass lastTD">4</td>
</tr>

I ended up doing the following as I have fixed columns 由于固定了列,我最终做了以下操作

thead>tr:first-child>th:first-child+th+th+th {
    color: red;
}
tbody>tr:first-child>td:first-child+td+td+td {
    color: red;
}

I did the above as first-child supports IE8 but not last-child . 我这样做是因为first-child支持IE8,但不支持last-child

It is working properly in IE8. 在IE8中它可以正常工作。

Source 资源

Anyway, I still don't know how to use selectivizr in project. 无论如何,我仍然不知道如何在项目中使用selectivizr

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM