>我无法在 Internet Explorer 中显示我的复选框。
它适用于所有其他 Web 浏览器,但只有 IE 无法正确显示它。
此外,它在我的本地计算机文件夹中确实可以正常工作,但是当它从网络(NAS)中的文件夹打开时无法显示<-使用IE打开。
由于工作相关,需要将其放置在网络上。我已经用火狐 26.0 和 IE 10.0.9
测试过
这是我的代码:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11 DTD/xhtml11.dtd"><html xsi:schemalocation="http://www.w3.org 1999/xhtml http://www.w3.org/MarkUp/SCHEMA/xhtml11.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml" version="-//W3C//DTD XHTML 1.1//EN">
<head>
<meta http-equiv="content-type" content="application/xhtml+xml; charset=windows-1252"/>
<style>
input[type=checkbox] {
display: none;
}
.checkbox label:before {
border-radius: 1px;
border: 1px solid black
}
input[type=checkbox]:checked + label:before {
content: "X";
text-shadow: 1px 1px 1px rgba(0, 0, 0, .2);
font-size: 22px;
color: #000000;
text-align: center;
line-height:19px;
border: 1px solid black
}
label {
display: inline-block;
cursor: pointer;
position: relative;
padding-left: 25px;
margin-right: 15px;
font-size: 16px;
font-weight: bold;
}
label:before {
content: "";
display: inline-block;
width: 15px;
height: 15px;
margin-right: 10px;
position: absolute;
left: 0;
bottombottom: 1px;
background-color: #eee;
box-shadow: inset 0px 2px 3px 0px rgba(0, 0, 0, .3), 0px 1px 0px 0px rgba(255, 255, 255, .8);
}
</style>
</head>
<body>
<div class="checkbox"> <input type="checkbox" id="Field1" name="testINPUT" fieldname="Vote" mandatory="false" value="VoteYes" /> <label for="Field1">Yes</label></div>
<div class="checkbox"> <input type="checkbox" id="Field2" name="testINPUT" fieldname="Vote" mandatory="false" value="VoteNo" /> <label for="Field2">No</label> </div>
</body>
</html>
发现复选框未显示
的问题原因的根源是当文件被放置在网络上并使用IE打开时,它以某种方式自动将文档模式更改为"Internet Explorer 7标准",当您将文件放在本地文件夹中时,这种情况不会发生。
因此,通过在代码中添加此行将强制在文档模式下运行:标准
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
有关兼容性的更多详细信息,您可以在以下 URL 中找到它:
https://hsivonen.fi/doctype/#ie8
正如预期的那样,使用 IE9 及更高版本对我来说工作正常。你真的需要相互冲突的文档类型和头部声明吗?XML 版本声明 UTF-8 和元标记"charset=windows-1252" 如果可以帮助它,我们尽量不要混淆浏览器。