Favicon不工作

th3*_*f98 12 html favicon

我试图插入我的网页的我的图标不起作用.有人能告诉我插入它需要的代码和样式吗?

<html>
    <head>
        <title>Welcome to Crash - Login or Signup</title>
        <link rel="stylesheet" type="text/css" href="crash_styling.css"></link>
        <link rel="icon" href="/favicon.ico" type="image/x-icon">
        <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon">      
    </head> 

    <body  link="#336666" alink="red" vlink="red">

        <div id="header_title">
            <h1 id="title">crash</h1>
            <p id="motto">Keep track of all your assignments and projects.</p>
        </div>  

        <form name="input" action="html_form_action.asp" method="get" id="user_passEntry">
            Username:<input type="text" name="username" placeholder="Your Username" /> <br />
            Password:<input type="password" name="password" placeholder="Your Password" />
            <input type="submit" value="submit">
        </form>

        <p id="description">Crash is a way students can keep track of their projects and assignments on the computer or on their devices. With crash, you can be sure you'll never turn in something late again.</p>

                <div class="make"><a href="crash_styling" style="text-decoration:none"/>Make a New Assignment</div>
                <div class="edit"><a href="crash_styling" style="text-decoration:none"/>Edit an Assignment</div>
                <div class="check"><a href="crash_styling" style="text-decoration:none"/>Check off an Assignment</div>
    </body> 

</html>
Run Code Online (Sandbox Code Playgroud)

Tar*_*ryn 24

要在您的网站上放置Favicon,您可以在<head>标记中使用以下内容

<link rel="shortcut icon" href="http://yourwebsitepath/favicon.ico" />
Run Code Online (Sandbox Code Playgroud)

您需要确保图标的路径正确.如果路径不正确,则不会出现.我也看到了缓存问题,使得图标似乎无法正常工作.清除缓存后,始终尝试重新启动浏览器.

  • 它在使用绝对URL时有效,但在从我的项目文件夹中使用本地主机时无效 (2认同)
  • 谢谢!!对我来说,它可能是缓存.这应该在某处记录!!!! 除非有人知道它的缓存,否则很难搞清楚.:) (2认同)
  • 对我来说,在 Chrome 上的本地主机中,即使在隐身模式下,图标也不会显示。然后我在firefox上测试了一下,可以用。 (2认同)

car*_*m85 14

有时强制重新加载(此链接中的其他维基百科信息)可以解决问题。您需要重新加载浏览器的缓存\xc3\xa9内存。

\n
    \n
  • 火狐浏览器:ctrl+shift+R
  • \n
  • Chrome:按住 ctrl 键并右键单击 Chrome 的重新加载按钮
  • \n
  • Edge:与 Chrome 相同,或 ctrl + F5
  • \n
\n

其他组合可以在上面提供的链接中找到。

\n


Sim*_*iak 5

很可能你的图标路径不好。确认您的文件路径。尝试使用

href="favicon.ico"
Run Code Online (Sandbox Code Playgroud)

代替

href="/favicon.ico"
Run Code Online (Sandbox Code Playgroud)

也许它会起作用。或者,如果您在某个文件夹中有图标,例如在图像中

href="images/favicon.ico"
Run Code Online (Sandbox Code Playgroud)

你做对了,但如果你的路径不好图标就不会出现。

所以你的CSS作品,如果你的图标与文件处于同一级别,CSS那么删除/它应该可以工作。