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 的第一个孩子和最后一个孩子


基础教程推荐
- WatchKit 支持 html 吗?有没有像 UIWebview 这样的控制器? 2022-01-01
- Node.js 有没有好的索引/搜索引擎? 2022-01-01
- 如何使用 CSS 显示和隐藏 div? 2022-01-01
- jQuery File Upload - 如何识别所有文件何时上传 2022-01-01
- 如何使用sencha Touch2在单页中显示列表和其他标签 2022-01-01
- Javascript 在多个元素上单击事件侦听器并获取目标 2022-01-01
- 如何在特定日期之前获取消息? 2022-01-01
- 每次设置弹出窗口的焦点 2022-01-01
- 什么是不使用 jQuery 的经验技术原因? 2022-01-01
- 为什么我在 Vue.js 中得到 ERR_CONNECTION_TIMED_OUT? 2022-01-01