简体   繁体   English

菜单在Firefox中无法正确显示

[英]Menu not showing correctly in Firefox

A site I'm creating is showing the front page exactly as its supposed to do in both Chrome and Safari, but when I test in Firefox the menu isn't showed correctly. 我正在创建的网站正像在Chrome和Safari中一样显示首页,但是当我在Firefox中进行测试时,菜单显示不正确。
- All browsers are the latest versions and on a mac. -所有浏览器均为最新版本,并且在Mac上。

Here's a screenshot comparing Firefox and Safari, respectively! 这是分别比较Firefox和Safari的屏幕截图!

And here's the css-code I use for the menu, pardon the mess. 这是我用于菜单的CSS代码,请原谅。

nav {
width: 650px;
height: 220px;
margin: 10px auto;
}

nav ul {
list-style: none;
margin: 0 auto;
display: block;
}

nav ul li {
margin: 10px;
display: inline-block;
height: 100px;
line-height: 200px;
}

I've tried with different methods, but this messes up the menu in the working browsers. 我尝试了不同的方法,但是这弄乱了工作浏览器中的菜单。

Here's the HTML code for the nav-bar, as per request: 这是根据请求的导航栏的HTML代码:

<nav>
<ul>
    <li><h2><a href="#cykler.html">Cykler</a></h2></li>
    <li><h2><a href="#service.html">Service</a></h2></li>
    <li><a href="#index.html"><img src="images/logo.png" name="logo" alt="Søgaard Cykler" width="220" height="200"></a></li>
    <li><h2><a href="#info.html">Info</a></h2></li>
    <li><h2><a href="#kontakt.html">Kontakt</a></h2></li>
</ul>
</nav>

And here is a link to the functioning code on jsfiddle: http://jsfiddle.net/DaCqS/ 这是jsfiddle上功能代码的链接: http : //jsfiddle.net/DaCqS/

It's best to avoid line-height for positioning elements. 最好避免定位元素的线高。 Margins are much more effective. 保证金要有效得多。 Get rid of the line-height and try using a 摆脱行高并尝试使用

margin-top:100px;

on either the nav or the ul. 在导航或在ul上。

EDIT : Now that I see your HTML... Since the big center logo is stylistically different from the four buttons, you should keep their CSS selectors separate. 编辑 :现在,我看到了您的HTML ...由于大的中心徽标在样式上不同于四个按钮,因此应将其CSS选择器分开。 None of your current CSS is able to differentiate between these four buttons and the big center logo. 您当前的CSS都无法区分这四个按钮和大中心徽标。 A quick and easy way to fix this is to add this style: 解决此问题的快速简便方法是添加以下样式:

nav ui li h2 {margin-top:100px;}

Ok so I've floated the the <li> and used the margin-top:100px for the h2. 好的,所以我浮动了<li>并为h2使用margin-top:100px。

try this and let me know if that fixes it http://jsfiddle.net/hfxKW/ 试试这个,让我知道是否可以解决它http://jsfiddle.net/hfxKW/

Does this work for you? 这对您有用吗? http://jsfiddle.net/WWkWw/ http://jsfiddle.net/WWkWw/

.top-menu{
    background-image:url('foo/logo.png');
    height:22px;
}
.left{
    float:left;
}
.right{
    float:right;
}
.top-menu li{
    margin:60px 10px 10px 10px;
    height:100px;
}

HTML: HTML:

<nav>
<ul class="top-menu">
<li class="left"><h2><a href="#cykler.html">Cykler</a></h2></li>
<li class="left"><h2><a href="#service.html">Service</a></h2></li>
<li class="right"><h2><a href="#info.html">Info</a></h2></li>
<li class="left"><h2><a href="#kontakt.html">Kontakt</a></h2></li>
</ul>
</nav>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM