Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/86.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/facebook/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 想要只使用css的特定于浏览器的链接吗_Html_Css - Fatal编程技术网

Html 想要只使用css的特定于浏览器的链接吗

Html 想要只使用css的特定于浏览器的链接吗,html,css,Html,Css,我想显示基于浏览器的链接。 例如:如果浏览器是chrome,我只想显示classname为“.for chrome”的链接,并隐藏其他链接 我尝试使用CSS,但它对chrome有效,但在firefox中,它隐藏了两个链接。 这是小提琴链接 @-moz文档url-prefix(){ .对于铬{ 显示:无!重要; } } @媒体屏幕和(-webkit最小设备像素比:0){ .对于firefox{ 显示:无!重要; } } 有人能帮我找到此问题的替代解决方案吗为什么不使用以下媒体查询: fir

我想显示基于浏览器的链接。 例如:如果浏览器是chrome,我只想显示classname为“.for chrome”的链接,并隐藏其他链接

我尝试使用CSS,但它对chrome有效,但在firefox中,它隐藏了两个链接。 这是小提琴链接

@-moz文档url-prefix(){
.对于铬{
显示:无!重要;
}
}
@媒体屏幕和(-webkit最小设备像素比:0){
.对于firefox{
显示:无!重要;
}
}


有人能帮我找到此问题的替代解决方案吗

为什么不使用以下媒体查询:

firefox的
{
显示:无!重要;
}
@-moz文档url-前缀(){
.对于铬{
显示:无!重要;
}
.for firefox{
显示:内联!重要;
}
}
但请注意,此解决方案只考虑(firefox,而不是firefox)浏览器状态,而不考虑其他浏览器。

函数myFunction(){
if((navigator.userAgent.indexOf(“Opera”)| | navigator.userAgent.indexOf(“OPR”)!=-1){
//是歌剧
让brow=document.querySelector(“.show opera”)
brow.classList.add('show')
}else if(navigator.userAgent.indexOf(“Chrome”)!=-1){
//是铬吗
让brow=document.querySelector(“.show chrome”)
brow.classList.add(“显示”)
}else if(navigator.userAgent.indexOf(“Safari”)!=-1){
//这是野生动物园吗
让brow=document.querySelector(“.show safari”)
brow.classList.add('show')
}else if(navigator.userAgent.indexOf(“Firefox”)!=-1){
//是火狐吗
让brow=document.querySelector(“.show firefox”)
brow.classList.add('show')
}else if((navigator.userAgent.indexOf(“MSIE”)!=-1)| |(!!document.documentMode==true))//如果IE>10
{
//是艾美吗
让brow=document.querySelector('.show ie')
brow.classList.add('show')
}否则{
//未检测到,可能显示所有链接
document.querySelector('.hide all').classList.add('show'))
}
}
myFunction()
。全部隐藏{
显示:无;
}
.表演{
显示:块
}


我刚在firefox中试用过,它对我很有效,我认为我们可以在js中使用navigator.userAgent.indexOf(“浏览器名称”)来查找浏览器,并根据它来显示和隐藏元素。