第一个孩子和最后一个孩子与IE8
我有一些调整我的桌子上的东西。
这里是:
.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; } 
它适用于Firefox,Safari和Chrome,但是不能(现在)使用IE8。
我知道问题来自第一胎和最后一胎,但我不是专家。
任何想法如何我可以fixt它?
  PS:我在我的html文档的顶部添加了<!doctype html> ,但没有任何改变。 
 如果你的表只有2列,你可以很容易地与相邻的兄弟select器, :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; } 
 否则,你将不得不使用像jQuery这样的JSselect器库,或者像James Allardice所build议的那样,手动向最后的td添加一个类。 
 由于:last-child是一个CSS3伪类,在IE8中不支持。 我相信:first-child是支持的,因为它是在CSS2.1规范中定义的。 
一个可能的解决scheme是简单地给最后一个孩子一个class级的名字和风格。
 另一个将是使用JavaScript。  jQuery使得这个特别简单,因为它提供了一个应该在IE8中工作的:last-child伪类。 不幸的是,这可能会导致在DOM加载时出现无格式的内容。 
如果你想继续使用CSS3select器,但需要支持旧的浏览器,我会build议使用像Selectivizr.js的polyfill