first-child and last-child with IE8(IE8 的第一个孩子和最后一个孩子)
问题描述
我有一些 css 用于调整我的表格中的东西.
I have some css for adjusting things in my table.
这里是:
.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.
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.
知道如何解决吗?
PS:我在我的 html 文档顶部添加了 <!doctype html>
但没有任何改变.
PS: I added <!doctype html>
on top of my html document but nothing changed.
推荐答案
如果你的表只有 2 列,你可以很容易地使用相邻的兄弟选择器到达第二个 td
,IE8 确实支持连同 :first-child
:
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;
}
否则,您将不得不使用像 jQuery 这样的 JS 选择器库,或者手动将类添加到最后一个 td
,James Allardice 建议.
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 的第一个孩子和最后一个孩子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:IE8 的第一个孩子和最后一个孩子


- Quasar 2+Apollo:错误:找不到ID为默认的Apollo客户端。如果您在组件设置之外,请使用ProvideApolloClient() 2022-01-01
- addEventListener 在 IE 11 中不起作用 2022-01-01
- 如何使用 JSON 格式的 jQuery AJAX 从 .cfm 页面输出查 2022-01-01
- 400或500级别的HTTP响应 2022-01-01
- 失败的 Canvas 360 jquery 插件 2022-01-01
- 使用RSelum从网站(报纸档案)中抓取多个网页 2022-09-06
- CSS媒体查询(最大高度)不起作用,但为什么? 2022-01-01
- Fetch API 如何获取响应体? 2022-01-01
- Css:将嵌套元素定位在父元素边界之外一点 2022-09-07
- Flexslider 箭头未正确显示 2022-01-01