我正在研究基于CSS的库,并且遇到了这个问题,因为处理它的最佳方法是什么.
而且我知道我们都有这个问题,因为IE在标准网络方面有一些意想不到的行为.所以我的问题不仅适用于Microsoft Internet Explorer,因为Microsoft Edge中仍然存在一些问题.
是的,我们可以通过检测浏览器和版本使用javascript来处理它.但整个想法是将它带到单个CSS文件.以及它的可能性.
所以使用Microsoft提供的方法或其他css hacks,
<!--[if lt IE 7]> <html class="ie ie6"> <![endif]-->
<!--[if IE 7]> <html class="ie ie7> <![endif]-->
<!--[if IE 8]> <html class="ie ie8"> <![endif]-->
<!--[if IE 9]> <html class="ie ie9"> <![endif]-->
<!--[if gt IE 9]> <html class="ie"> <![endif]-->
<!--[if !IE]><!--> <html> <!--<![endif]-->
Run Code Online (Sandbox Code Playgroud)
要么
<!--[if IE]>
<link rel="stylesheet" type="text/css" href="ie-only.css" />
<![endif]-->
Run Code Online (Sandbox Code Playgroud)
这仅支持IE9,它已经停止支持并最新引入CSS查询.而我个人认为这html有点混乱.因为当我们编写基于CSS的库时,这看起来很难看.
/* For IE 8 & Lower css hacks */
.some-class {
margin-top: 10px\9 …Run Code Online (Sandbox Code Playgroud) 我在 html 中创建了一个 div,其中创建了一个文本框并为其分配了背景图像,我想为该输入字段的背景图像创建一个 onclick 事件。
document.getElementsByClassName("textboxcss").onclick = function() {
alert("Hello");
};Run Code Online (Sandbox Code Playgroud)
.textboxcss {
background-image: url("../images/sub.png");
background-repeat: no-repeat;
background-position: right;
background-position: 8px 13px;
}Run Code Online (Sandbox Code Playgroud)
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<div>
<input class="textboxcss" id="default" type="text">
</div>Run Code Online (Sandbox Code Playgroud)
我看到图像正确...但我无法以这种方式单击。还有其他办法吗?
我正在为托架编写CodeMirror扩展。为了定义defineSimpleCodeMode,我需要进行一些模式匹配,并且试图弄清楚如何实现$ subject。
例如
匹配<所有html标签
<body>
Run Code Online (Sandbox Code Playgroud)
并忽略html标签,其后是 <%
<% if %>
Run Code Online (Sandbox Code Playgroud)
注:我只想要得到的开始<吧
如果有人可以帮助我,那将是一个很大的帮助。如果您需要更多详细信息,请告诉我。
谢谢!