第一个孩子和最后一个孩子与IE8 [英] first-child and last-child with IE8

查看:110
本文介绍了第一个孩子和最后一个孩子与IE8的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些css调整我的表中的东西。



这是:

  .editor td:first-child 
{
width:150px;
}

.editor td:last-child输入,
.editor td:last-child textarea
{
width:500px;
padding:3px 5px 5px 5px;
border:1px solid #CCC;
}

它适用于Firefox,Safari和Chrome,但不能(此时) IE8。



我知道问题来自第一胎和最后一个孩子,但我不是专家。


$ b $



PS:我添加了<!doctype html>

解决方案

如果你的表只有两列,你可以很容易地到达第二个 td 与相邻的同级选择器,IE8与一起支持:first-child

  .editor td:first-child 
{
width:150px;
}

.editor td:first-child + td input,
.editor td:first-child + td textarea
{
width:500px ;
padding:3px 5px 5px 5px;
border:1px solid #CCC;
}

否则,必须使用JS选择器库手动将类添加到最后的 td 由James Allardice建议


I have some css for adjusting things in my table.

Here it is:

.editor td:first-child
{
    width: 150px; 
}

.editor td:last-child input,
.editor td:last-child textarea
{
    width: 500px;
    padding: 3px 5px 5px 5px;
    border: 1px solid #CCC; 
}

It works with Firefox, Safari and Chrome but not (at this time) with IE8.

I know the problem comes from the first-child and last-child but I'm not an expert.

Any idea how I can fixt it?

PS: I added <!doctype html> on top of my html document but nothing changed.

解决方案

If your table is only 2 columns across, you can easily reach the second td with the adjacent sibling selector, which IE8 does support along with :first-child:

.editor td:first-child
{
    width: 150px; 
}

.editor td:first-child + td input,
.editor td:first-child + td textarea
{
    width: 500px;
    padding: 3px 5px 5px 5px;
    border: 1px solid #CCC; 
}

Otherwise, you'll have to use a JS selector library like jQuery, or manually add a class to the last td, as suggested by James Allardice.

这篇关于第一个孩子和最后一个孩子与IE8的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆