CSS chrome/firefox 之间的背景位置变化

CSS background-position variation between chrome/firefox

我正在为期末项目创建一个网站,我遇到了导航图像背景位置在浏览器(主要是 Firefox)之间变化的问题。

这可以通过单击 link 到我上传到我学院服务器的页面来演示:http://cis.scc.losrios.edu/~cisw320q_stu007/sbc/index.html。交替使用的视口 (Chrome/Firefox) 将显示我所说的定位差异。 Chrome 正确显示背景位置("Business BLDG" 位于学校标志的正下方)。

我可以使用 CSS 技巧来缓解这个问题,以便所有视口之间的背景定位是静态的吗?

谢谢!

主导航代码:

div#nav {
width: 1024px;
border-bottom: 3px solid #fff;
border-top-left-radius: 25px;
border-top-right-radius: 25px;
background-color: #660000;
background: url(http://i60.tinypic.com/i6gn5x.jpg);
background-position-y: 53.75%;
color: #fff;

}

您可以使用此代码段专门针对 Firefox 并为其设置正确的背景位置。

@-moz-document url-prefix() { 
    /* Your styling for Firefox goes here */
    div#nav{
       /* background-position: firefox-value */
    }
}
background-position-y: 53.75%;

background-position: 0 53.75%;

/* NAViGATiON START */

div#nav {
width: 1024px;
border-bottom: 3px solid #fff;
border-top-left-radius: 25px;
border-top-right-radius: 25px;
background-color: #660000;
background-image: url("http://i60.tinypic.com/i6gn5x.jpg");
background-position: 0 53.75%;
color: #fff;
}

div#nav h1 {
  text-align: center;
  margin: 0;
  border-top-left-radius: 25px;
  border-top-right-radius: 25px;
  background-color: rgba(102,0,0,.91);
  font-family: sans-serif;
}

div#nav ul {
  list-style-type: none;
  text-align: center;
  margin: 0 auto;
  margin-left: -35px;
  border-top: 3px solid #fff;
}

div#nav ul li {
  display: inline-block;  
  border: 4px solid #000;
  margin-left: -5px;
  width: 197.6px;
  height: 100px;
  line-height: 5;
  background-color: rgba(34,34,34,0.2);
}

div#nav ul li a {
  color: #fff;
  text-decoration: none;
  font-family: verdana;
  font-size: 1.2em;
}

div#nav ul li:hover {
  background-color: rgba(34,34,34,0.8);
}

div#nav ul li a:hover {
  color: #FFCC00;
  -webkit-transition: all 1.5s;
}
<div id="nav">
    <h1><img src="http://i60.tinypic.com/28i2o9e.png"></font><br> City Business Center</h1>
    <ul>
      <li><a href="#" title="Go back to the Business Center Homepage" alt="site index">Home</a></li>
      <li><a href="#" title="Find out more about us; our mission statement and history can be found here." alt="about us">About</a></li>
      <li><a href="#" title="Use this form to contact us for any non-work related inquiries!" alt="contact">Contact</a></li>
      <li><a href="#" title="Petition the business center for specific  services." alt="petition for services">Petition</a></li>
      <li><a href="#" title="Want to support your local community college and help fund potential educational programs and outreach? Click here.">Donate</a></li>
    </ul>
  </div>