<script type="text/javascript">
var isChrome = /Chrome/.test(navigator.userAgent) && /Google
Inc/.test(navigator.vendor);
if (isChrome) {
document.write('<'+'link rel="stylesheet"
href="css/framesmainchrome.css" />');
}
/script>
在上面的脚本中,我得到了Chrome浏览器,我可以轻松地为chrome浏览器应用特定的CSS文件。
我想为Mozilla Firefox浏览器应用另一个CSS文件,因此请修改上面的脚本,为我的问题提供解决方案。
好的,我找到了。这可能是目前最干净,最简单的解决方案,并且不依赖于打开JavaScript。
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
@-moz-document url-prefix() {
h1 {
color: red;
}
}
</style>
</head>
<body>
<h1>This should be red in FF</h1>
</body>
</html>
它基于另一个Mozilla特定的CSS扩展。这里有一个完整的CSS扩展列表:https://developer.mozilla.org/en-US/docs/Web/CSS/Mozilla_Extensions