html - 针对所有非 firefox 浏览器。最简单的方法

标签 html css firefox mobile cross-browser

我想为 firefox 浏览器显示不同的代码,为所有其他浏览器显示另一个代码。这包括 IE、Chrome、Safari、Opera 和移动浏览器在内的所有版本。

<div class="firefox"> 
<p>This should be only shown in firefox browser versions.</p>
</div>

<div class="nonfirefox"> 
<p>This should be only shown in non-firefox browsers including mobile.</p>
</div>

两者不会出现在同一个浏览器中,这一点非常重要。

我可以很容易地做到这一点来隐藏非 firefox 版本。

@-moz-document url-prefix () { 
.nonfirefox { 
    display:none;
    }
}

但是隐藏在其他浏览器中显示的 firefox 版本的最简单方法是什么。

最佳答案

// Hide in Chrome, Safari, ...
.firefox {
    display:none;
    }

// Show in firefox
@-moz-document url-prefix() { 
.nonfirefox { 
    display:none;
    }
.firefox {
    display:block;
    }
}

关于html - 针对所有非 firefox 浏览器。最简单的方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33895602/

相关文章:

javascript - Bootbox.js 模态禁用脚本

javascript - 为什么 attributeChangedCallback 被调用了两次?

javascript - 突出显示图像区域 - 单击链接时

javascript - 当DIV低于某个特定值时自动设置DIV的高度

javascript - 错误类型对象在 Internet Explorer 上不支持这种属性或方法

javascript - 如何设置/检测页面中浏览器 native 搜索生成的突出显示框

html - 清除 popstate 事件的转发历史记录

Jquery, View /链接悬停中的 Div,固定菜单 "pop out"

javascript - 如何使用 jQuery UI 选择菜单创建自定义颜色选择器下拉菜单?

css - Firefox 中的表单按钮未对齐