Internet Explorer 8如何支持CSS的outline属性?

3
网站表示已支持,但以下样式无法呈现。

    <style type="text/css">
        a[href="#"]{outline:#f00 dotted 2px !important}
    </style>

然而,以下内容将呈现。

    <style type="text/css">
        a[href="#"]{border:#f00 dotted 2px !important}
    </style>

这是我的文档


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
   <title>...</title>
   <link type="text/css" rel="stylesheet" href="../content/style.css" />

</head>
<body>...</body>
</html>

你确定这个规则会被应用吗?我认为IE8支持属性选择器(http://www.quirksmode.org/css/contents.html),但最好还是确认一下。 - Dominic Rodger
你的页面只支持标准模式,你的页面使用了哪种渲染模式? - Alex Gyoshev
2个回答

8

检查IE8是否以兼容模式渲染。如果您的头文件中有以下内容,则大纲将无法正常工作:

<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" >

如果文档类型标签不正确,IE8 也会默认使用怪异模式,因此请确保此标签正确。另外,如果您正在使用IIS,则服务器可能会强制使用IE7兼容模式。


我已经在我的原始问题中添加了文档头。它是 XHTML 1.0 严格模式,并通过验证。 - David
就是这样,我开启了兼容模式。 - David

2

可能是因为链接在浏览器中显示的不是#而是yourpage.html#

尝试改用 ends-with:

<style type="text/css">
    a[href$="#"]{outline:#f00 dotted 2px !important}
</style>

边框不同于轮廓线。他只是指出他使用的选择器适用于他的目的。 - David Ma

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接