我在本网站的导航栏中使用树叶作为项目的背景图像。在 Chrome 和 Safari 中一切看起来都很好,但在 Firefox 中,三个叶子在 x 轴上的不同位置呈现,如下图所示:
唯一在正确位置渲染的叶子是“关于我”叶子。'home' 叶的渲染比应有的低约 20px,而 'contact' 叶的渲染低约 5px。我想知道是否有人可以发现为什么会这样?
叶子和css的html如下:
HTML
<nav>
<a href="/index.html" id="home"><img class='hoverImg_normal' src='images/bodhi-leaf-brown.png'/><img class='hoverImg_highlight' src='images/bodhi-leaf-green.png'/><img class='text home' src='images/home.png'/></a>
<a href="about.html" id="about"><img class='hoverImg_normal' src='images/bodhi-leaf-brown.png'/><img class='hoverImg_highlight' src='images/bodhi-leaf-green.png'/><img class='text about' src='images/about.png'/></a>
<a href="contact.html" id="contact"><img class='hoverImg_normal' src='images/bodhi-leaf-brown.png'/><img class='hoverImg_highlight' src='images/bodhi-leaf-green.png'/><img class='text' src='images/contact.png'/></a>
</nav>
CSS
nav{
text-align:center;
height:170px;
}
nav a{
width:115px;
height:170px;
display:inline-block;
margin: 0 50px;
}
nav a>img{
width:115px;
height:170px;
}
nav a>img.hoverImg_normal{
position:relative;
left:0;
z-index:2;/*Put image behind text*/
}
nav a>img.hoverImg_highlight{
position:relative;
left:0;
top:-174px;/*5 + 1 for text*/
opacity:0;
transition: 1s;
-moz-transition: 1s; /* Firefox 4 */
-webkit-transition: 1s; /* Safari and Chrome */
-o-transition: 1s; /* Opera */
z-index:2;
}
nav a:hover>img.hoverImg_highlight{
opacity:1;
}
nav a>img.text {
position: relative;
z-index: 3;
width: auto;
height: auto;
top:-267px;
}
.about {
margin-top: 3px;
}
.home {
margin-top: 8px;
}