html - 使用兼容所有浏览器的 css 和 li 元素创建菜单

标签 html css internet-explorer firefox

我正在尝试使用 li 元素创建一个简单的菜单,但它只适用于 IE7,在 FF 和 Chrome 中,对齐变得奇怪。 :hover 和 :Active 也只适用于 IE7。

谁能帮我解决这个问题?

非常感谢。

CSS:

#heading{
    width: 700px;
   height:auto; 
    margin: 0 auto;
    background-color:#FFFFFF;
    margin-top:5px;
    margin-bottom:5px;
    display:block;
}
#imglogo{
 float:left;

}

#barDescription{
    float:right;

}



#navigation{
    text-align: right;
    margin-top: 70px;
}

#navigation li{
    float: right;
    display: block;
    text-align: center;
    list-style-type: none;  
}
#navigation li a{

    color:#A08019;
    background-image: url('Images/Menu1.png');
    background-repeat:repeat-x;
    background-position: center center;
        text-decoration:none;   
        font-weight:bold;
    display: block;
    height:25px;
    vertical-align:middle;
        padding-right:10px;
        padding-left:10px;
}

navigation li a:hover{
    color:white;
    background-image: url('Images/Menu2.png');
    background-repeat:repeat-x;
    background-position: center center;
    text-decoration:none;   
    font-weight:bolder;
    display: block;
    height:25px;
    vertical-align:middle;
    padding-right:10px;
    padding-left:10px;


}
navigation li a:active{
    color:#B39A48;
    background-image: url('Images/Menu2.png');
    background-repeat:repeat-x;
    background-position: center center;
    text-decoration:none;   
    font-weight:bolder;
    display: block;
    height:25px;
    vertical-align:middle;
    padding-right:10px;
    padding-left:10px;


}

HTML:

<div id="heading" >
    <div id="imglogo">
        <img id="logo" src="Images/logo.png" alt="logo" />
    </div>
    <div id="barDescription">
       <h4>Especialidad en tapas,vinos y menus</h4>
       <h5>Restaurante de cocina creativa tradicional. Vinos y tapas</h5>
    </div>

    <ul id="navigation">
       <li><a href="#">Contacto</a></li>
       <li><a href="#">Ubicacion</a></li>
       <li><a href="#">Reservas</a></li>
       <li><a href="#">Menus</a></li>
       <li><a href="#">Local</a></li>
    </ul>

    </div>

最佳答案

Suns of Suckerfish教导如何到达那里。 ( Example .)

编辑:现在您发布了 :active:hover CSS,我可以看到您在开头缺少 #的规则。因此,它被应用于“导航”标签,而不是带有“导航”id 的标签。更改您的 CSS 以在“导航”之前添加 #:

#navigation li a:hover{
  /* ... */
}
#navigation li a:active{
  /* ... */
}

关于html - 使用兼容所有浏览器的 css 和 li 元素创建菜单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2883638/

相关文章:

html - Twitter URL 中的 (#!) 有什么作用?

html - css 反射问题 - 反射图像的错误部分

css - <br> &#10 &#xa 里面 <h :commandButton value> not interpreted as linebreak

html - 是否可以在 DIV 背景图像标签中使用 'responsive' 图像?

html - 将图像放在 Twitter Bootstrap 的网格中

javascript - 为什么这个 HTML/JS 在更改内部 HTML 后会恢复到原来的状态?

CSS 变换缩放动画在 Firefox 中不起作用

HTML 元素 COL、颜色和宽度 CSS 属性不起作用

javascript - 如何在添加选项时保持 HTML 选择扩展

javascript - 使用 IE9 上传之前在 Div 中预览图像