为什么我的网站图标可以在 Firefox 上运行,但 Chrome、Opera GX、Brave 不显示它?

Why does my website's icon work on Firefox but Chrome, Opera GX, Brave do not display it?

提问人:Jirafey 提问时间:1/4/2023 更新时间:1/5/2023 访问量:71

问:

我尝试了很多东西,favicon.ico 是 16x16 我尝试过 png 图像,但没有运气,有趣的是我的网站曾经有相同的图标,但我在那里更改了很多东西,现在它不起作用。

网址: https://grzegorzkmita.com

整个网站: https://github.com/Jirafey/grzegorzkmita.com

HTML格式:

<DOCTYPE>
<html lang="pl">
<head>
<link href="icon/favicon.ico" rel="shortcut icon" type="image/x-icon"/> 
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<meta name="viewport" content="width-device-width, initial-scale=1.0">
<title>Grzegorz Kmita</title>

    <!-- google adsense # 1 -->
    
    <script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-5445347292860263"
     crossorigin="anonymous"></script>



<link href="style.css" rel="stylesheet" type="text/css" media="screen" />
    
<!-- <link rel="icon" type="image/vnd.microsoft.icon" href="icon/icon01.ico"> -->
<div class= "pages"><h2 class = "banner">   <a href="TFT/">TFT</a></h1>
    <h2 class="banner"><a href="japanese/">Japanese reading practice</a> </h1>
    </head>
    <body>
</div>

    <p>My main programming language - Python</p>
    <p>I'm also familiar with C++,C, HTML, CSS and Javascript</p>
    <p>I have a good understanding of Microsoft Access, Excel </p>
    <p>I am open to job offers</p>
        
    <script>
        function copyEvent(id)
        {
            var str = document.getElementById(id);
            window.getSelection().selectAllChildren(str);
            document.execCommand("Copy")
        }
    </script>
    
    <h2>Contact me:</h2><p class="copy" id="p-copy">[email protected]</p><button class = "copy" type="button" onclick="copyEvent('copy')">Copy</button>
    
<h2>Find me:  </h2>
<div class="icons">
  <figure><a href="mailto:[email protected]" id="[email protected]">
    <img src="images/email.png" lang="en-GB"><figcaption class="email"></figcaption>        </a>
</a></figure>
    <figure><a href="https://github.com/Jirafey">
      <img src="images/github.png" lang="en-GB">
    </a></figure>
    <figure><a href="https://www.linkedin.com/in/grzegorz-kmita-aa22a2260/">
        <img src="images/linkedin.png" lang="en-GB">
      </a></figure>
      <figure><a href="https://jirafey.itch.io/">
        <img src="images/itch.png" lang="en-GB">
      </a></figure>
  </div>
    <p><a href = "https://github.com/Jirafey"> </a> </p>
    <h2>Resume:  </h2>
    <iframe class="pdf"src="images/pdf/grzegorz-kmita-resume.pdf" width="50%" height="750px">
    </iframe>


<!-- google adsense -->
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-5445347292860263"
     crossorigin="anonymous"></script>


</body>
</html>

CSS:

body{
    background-color: black;
    color: #ddd;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;

    
}
.copy{
    justify-content: center;
    display: flex;
    align-items: center;
    margin: auto;
}
p{  
    justify-content: center;
    display: flex;
    align-items: center;
    margin: auto;
}

h2{
    justify-content: center;
    display: flex;
    align-items: center;
    margin-top: 1vh;
    margin-left: auto;
    margin-right: auto;
    margin-bottom: auto;
}

.pdf{
        justify-content: center;
        display: flex;
        align-items: center;
        margin: auto;
        height: 60%;
        width: 30%;
}
.banner{
    display: inline;
    justify-content: inline;
    align-items: inline;
    margin-left: 1vw;
    margin-right: 1vw;
    color: rgb(199, 206, 206);
    
    font-family: "Avenir LT Std", sans-serif;
}

.pages{
    background-color: rgb(142, 142, 142);
    text-align: center;
}
.copy{

    border-radius: 10px;
    padding: 3px;
    align-items: flex;

}
a, a:hover, a:focus, a:active {
    text-decoration: none;
    color: inherit;
    text-align: center;
}   

.icons{
    display: flex;
    flex-wrap: wrap;
    align-content: space-between;
    justify-content: center;
    margin: 0;
  }
figure{
    margin: 1vw;
}
.icons > figure > a > img {
    filter: grayscale(1);
    vertical-align: middle;
    width: 2em;
    margin: 0;  
  }
HTML 网站图标 ICO

评论

1赞 pierpy 1/4/2023
只是一个旁注,在 html/css 中没有任何意义width-device-width
0赞 Rob 1/5/2023
不是修复,但请注意,<link> 标签不使用也不需要右斜杠,也从未在任何 HTML 规范中使用过。

答:

2赞 Dorvalla 1/4/2023 #1

我从未遇到过它,但我总是在系统中有回退。

<link  rel='apple-touch-icon' sizes='180x180' href='theme/ico/apple-touch-icon.png'/>
<link  rel='icon' type='image/png' sizes='32x32' href='theme/ico/favicon-32x32.png'/>
<link  rel='icon' type='image/png' sizes='16x16' href='theme/ico/favicon-16x16.png'/>
<link  rel='manifest' type='image/x-icon' href='theme/ico/site.webmanifest'/>

顺便说一句,Safari 浏览器处理的事情不同,因此额外的 Apple touch 图标,此外,当您将网站保存在 Iphone / Ipad 或任何其他允许将其作为快捷方式的 Apple 设备上时,它看起来更好。

我有几种尺寸的图标,所以我确实有一个回退,在最坏的情况下,我参考清单,据我所知,这几乎是一个 json 字符串,有助于在 android 和 chrome 上处理图标。

例如。

{"name":"","short_name":"","icons":[{"src":"/android-chrome-192x192.png","sizes":"192x192","type":"image/png"},{"src":"/android-chrome-512x512.png","sizes":"512x512","type":"image/png"}],"theme_color":"#ffffff","background_color":"#ffffff","display":"standalone"}

评论

0赞 Jirafey 1/4/2023
我删除了' ;”'它起作用了!非常感谢。另一件事,我应该制作一个清单文件还是只是默认文件?
0赞 Dorvalla 1/5/2023
对不起,这是我的PHP文件中的复制粘贴工作。我忘了我留下了结尾引号和分号。如果这对您有帮助,请接受它作为正确的答案。