2009-10-08 61 views
3

website表示支持,但以下样式不显示。Internet Explorer 8如何支持CSS大纲属性?


    <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> 
+0

你确定规则被应用?我认为IE8支持属性选择器(http://www.quirksmode.org/css/contents.html),但这值得检查。 – 2009-10-08 14:04:18

+0

它仅在标准模式下受支持......您的页面处于什么渲染模式? – 2009-10-08 14:06:20

+0

doctype是xhtml 1.0严格 – Dave 2009-10-08 14:14:24

回答

8

检查IE8是否在兼容模式下呈现。如果你有什么喜欢在你的头下,然后大纲将无法正常工作:

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

IE8也将默认为怪癖模式,如果你的DOCTYPE标记不正确,那么验证这一点。另外,如果您使用的是IIS,则服务器可能会强制使用IE7兼容模式。

+0

我已将我的文档头添加到原始问题中。它是XHTML 1.0严格,它验证 – Dave 2009-10-08 14:20:46

+0

是这样的,我打开兼容模式 – Dave 2009-10-08 14:23:25

2

也许因为链接不会在浏览器中显示为#yourpage.html#

尝试使用结尾 - 而不是:

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

a [href =“#”] {border:#f00 dotted 2px!important}作品 – Dave 2009-10-08 14:13:35

+0

@James边框作品,轮廓不起作用 – Dave 2009-10-08 14:19:43

+0

边框与大纲不一样。他只是指出他使用的选择器是用于他的目的。 – 2009-10-08 14:20:19