CSS和favicon在直接IP和DNS地址之间有所不同

时间:2014-06-05 00:18:55

标签: html css favicon

我正在从家中托管的网站上工作,看到网站的直接IP版本与DNS版本之间存在差异。

DNS网站:

  • 没有favicon。
  • html / body周围没有边距。!
  • Example

IP网站:

  • Favicon出现。
  • 显示8像素的边距。
  • Example

的index.html:

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="***">
    <meta name="author" content="***">
    <link rel="shortcut icon" href="/resources/img/favicon.ico" />

    <title>***</title>

    <link href="/resources/css/main.css" rel="stylesheet">

  </head>
  <body>
    <div>
      <div class="titles">
        <center>
          <h2><a href="/index.html">***</a></h2>
          <h3><a href="/resources/doc/resume.pdf">Résumé</a> | <a href="https://github.com/SWPhantom" target="_blank">Github</a></h3>
          <br><br>
          <h2>Web Project Gallery</h2>
          <h3><a href="/flights/index.html">Safe Flights</a></h3>
        </center>
      </div>
      <div class="footer">
        <center>
          <a href="http://github.com/SWPhantom/" target="_blank">
          <img src="/resources/img/octocat.png" height="32" width="32"></a>
          <a href="http://***.tumblr.com/" target="_blank">
          <img src="/resources/img/tumblr.png"></a>
          <a href="http://twitter.com/***/" target="_blank">
          <img src="/resources/img/twitter.png" height="32" width="32"></a>
        </center>
      </div>
    </div>
  </body>
</html>

的main.css:

html, body {
  font-family: 'AvenirLT-Heavy', sans-serif;
  color: #010101;
  height: 100%;
  background-color: #dddddd;
  background-repeat: no-repeat;
  background: -webkit-linear-gradient(#dddddd, #000000); /* For Safari 5.1 to 6.0 */
  background: -o-linear-gradient(#dddddd, #000000); /* For Opera 11.1 to 12.0 */
  background: -moz-linear-gradient(#dddddd, #000000); /* For Firefox 3.6 to 15 */
  background: linear-gradient(#dddddd, #000000); /* Standard syntax */
}

修复保证金问题的补充:

margin: 0;
然而,这让我有点不舒服。我假设通过直接IP进入网站应该与使用DNS没有什么不同。

任何人都可以解释为什么会发生这种情况(并帮助我让favicon显示在网站的DNS版本中)?

NameCheap上的DNS设置: enter image description here

1 个答案:

答案 0 :(得分:1)

网络服务器在请求中为不同的主机名使用不同的文件集并不罕见。实际上,如果Web服务器应该能够同时提供多个域或主机名,那么这是必要的。您可能已在Web服务器上设置了虚拟主机,其文档根目录不同于&#34;默认&#34; Web主机,用于在没有其他虚拟主机与请求匹配时通过。假设两个请求都到达同一个界面,您看到的效果与DNS设置无关。