gpt4 book ai didi

css - 隐藏特定浏览器的代码

转载 作者:太空宇宙 更新时间:2023-11-04 05:20:55 25 4
gpt4 key购买 nike

例如,如果我有一段简单的代码

<div> Test Div </div>

我想知道如何(使用 CSS)让这个 Div 仅对特定浏览器的用户显示。

例如,如果我想构建一个“仅限 Chrome 的功能”,比如图像或 div,该怎么办?如何指定不在 Firefox 和 IE 中显示?

最佳答案

I'm doing it for all the wrong reasons, I have a garbage site I'm working on. So I used a hacked fix to make something sit where I want it to and it works in every browser except Firefox so I want to just remove the image in FF.

要仅在 Firefox 中隐藏图像,请使用:

@-moz-document url-prefix() {
#myImg {
display: none
}
}

参见:https://developer.mozilla.org/en/CSS/@-moz-document

这比使用 JavaScript 更干净(也更可靠),至少对于您的用例而言。

如果解决方案是仅在 Firefox 中隐藏图像,我确实认为您做错了

关于css - 隐藏特定浏览器的代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6587930/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com