CSS 和 Internet Explorer 的 :last-child 伪类选择器
问题说明
我有以下代码:
ul.myList li{
border-right: 1px dotted #000;
}
但是,在最后一个元素上,我需要删除该边框,因为我正在使用的设计表明最后一项不需要边框作为分隔符.
However, on the last element, I need to remove that border as the design that I am working from dictates that the last item does not require a border as a separator.
所以,我需要定位列表的最后一个子元素,因此在我的 CSS 中添加了
So, I need to target the last child of a list and so within my css I have added
ul.myList li:last-child{
border-right: none;
}
众所周知,它在 Firefox、Safari 和 Chrome 中运行良好.
Which as we all know, works fine in Firefox, Safari and Chrome.
问题出在我们在 Internet Explorer 6 到 8 中查看页面时.
The problem lies when we view the page in Internet Explore 6 through to 8.
正确答案
所以,经过一番挖掘,我找到了答案:
So, after some digging around, I found the answer:
如果浏览器是 IE<8,请指定如下样式表:
If the browser is IE<8, specify a stylesheet like this:
<!--[if lt IE 8]>
<link rel="stylesheet" href="https://www.swvq.com/css/ie_all.css" type="text/css" />
<![endif]-->
并在您的 IE 样式表中指定以下规则:
And within your IE stylesheet specify the following rules:
ul.myList li{
border-right: expression(this.nextSibling==null?'none':'inherit');
}
nextSibling
表达式查看其后是否有元素,是否继承默认样式表中指定的规则,如果没有则应用新规则.
The nextSibling
expression looks to see if there is an element after it and if there is inherits the rule specified in the default stylesheet, if not it applys a new rule.
更多信息可以在这里找到
这篇好文章是转载于:学新通技术网
- 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
- 本站站名: 学新通技术网
- 本文地址: /reply/detail/tangibcbh
-
Reaction本机IOS Safari没办法打开页面,因为该地址在有效登录后无效
it1352 06-07 -
复制文件夹/文件而不修改属性?
it1352 07-15 -
使用c++17更新时出现G++编译器警告
it1352 06-18 -
在没有特定应用程序的情况下读取 NFC 标签?
it1352 08-02 -
应用已在 Play 商店发布,但未显示在平板电脑上
it1352 07-20 -
在不打开短信界面的情况下从 iPhone 应用发送短信?
it1352 07-25 -
从iOS应用程序打开Telegram聊天(使用Bot)
it1352 06-07 -
条形码(代码128)字体不能扫描有问题
it1352 06-09 -
检测是否安装了 Microsoft Edge?
it1352 08-02 -
手机号码拆分为国家代码、地区代码和本地号码?
it1352 09-15