CSS/XHTML 菜单 - 在所有浏览器中工作 - IE6 帮助

发布于 2024-10-29 08:05:50 字数 194 浏览 2 评论 0原文

我发现这个菜单正是我想要的。它适用于所有现代浏览器和 IE 7/8。我需要找到一个修复程序才能在 IE6 中工作。任何帮助将不胜感激。

http://lab.returnwt.net/htmlcss/tabmenu/

i found this menu that's exactly what i want. It works in all modern browsers and IE 7/8. I need to find a fix for it to work in IE6. Any help would be greatly appreciated.

http://lab.returnwt.net/htmlcss/tabmenu/

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

执妄 2024-11-05 08:05:50

IE6 中此菜单的问题在于它使用如下选择器:

header ul#menu li:hover ul

IE6 仅支持 a 元素上的 :hover

幸运的是,有一个非常简单的修复方法可以使该菜单在 IE6 中正常工作。

它叫做 Whatever:hover

  • 下载(缩小的)csshover3.htc 文件。
  • 添加此 CSS:

    <前><代码>正文{
    行为: url("csshover3.htc");
    }

这是一个独立的文件,我测试了它可以与 IE6 一起使用,前提是 csshover3.htc 文件位于同一文件夹中:

<!DOCTYPE html>
<html>
<head>
<title>Simple Tabbed Navigation - CSS3</title>
<!--[if lt IE 9]><script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script><![endif]-->
<meta charset="utf-8" />

<style>
body {
   behavior: url("csshover3.htc");
}

body
{
    background: #efefef url(images/bg_main.png);
    font: 13px Helvetica, Arial;
    margin: 0;
}

header
{
    background: url(images/bg_head.png);
    display: block; /* Compatibility fix */
}

header:after
{
    background: rgba(0, 0, 0, 0.1);
    content: ' ';
    height: 1px;
    position: absolute;
    width: 100%;
    z-index: 10;
}

header ul#menu
{
    border-bottom: 5px solid #fff;
    margin: 0;
    overflow: hidden;
    padding: 0 10px;
    padding-top: 100px;
    list-style: none
}

header ul#menu li
{
    float: left;

}

header ul#menu li a
{
    background: #b1d0dd;
    border-top: 1px solid #d0e2ea;
    color: #fff;
    font-weight: bold;
    display: block;
    line-height: 34px;
    margin-right: 2px;
    padding: 0 20px;
    text-decoration: none;
    text-shadow: 0 -1px rgba(0, 0, 0, 0.25);

    border-radius: 3px 3px 0 0; /* Currently working on Firefox 4.0b (Nightly), Chrome 8.0.xxxx and Opera 10.63+ */

    background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#B1D0DD), to(#89b8cc));
    background-image: -moz-linear-gradient(top, #B1D0DD,    #89B8CC);
}

header ul#menu li > ul
{
    display: none;
}

header ul#menu li a:hover
{
    background: #fff;
    border-top-color: #fff;
    color: #666;
    text-shadow: none;
}

header ul#menu ul {
    background: #fff;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    display: none;
    margin-left: 0;
    margin: 0;
    padding: 5px 0 0 0;
    position: absolute;
    z-index: 999;
}

header ul#menu ul li
{
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-width: 0 1px;
    float: none;
    list-style: none;
    margin: 0;
    padding: 0;
}

header ul#menu ul li a
{
    background: none;
    border-bottom: 1px solid #ededed;
    border-top: none;
    color: #666;
    font-weight: normal;
    font-size: 12px;
    margin: 0 20px;
    padding: 0;
    text-shadow: none;
    width: 118px;
}

header ul#menu li a.home-icon span
{
    background: url(images/home-icon.png) no-repeat center center;
    display: block;
    text-indent: -999em;
    overflow: hidden;
    text-align: left;
    direction: ltr;
    width: 16px;
}

header ul#menu li a.home-icon:hover span
{
    background-image: url(images/home-icon-hover.png);
}

header ul#menu ul li:last-child a
{
    border-bottom: none;
}

header ul#menu li:hover ul
{
    display: block;
}

header ul#menu ul li a:hover
{
    color: #000;
}

header ul#menu ul li:last-child
{
    border-bottom: none
}
</style>

</head>
<body>  
    <header>
        <ul id="menu">
            <li><a href="#homepage" class="home-icon"><span>Home</span></a></li>
            <li>
                <a href="#">Community</a>
                <ul>
                    <li><a href="#">Recent Activity</a></li>
                    <li><a href="#">Member Forum</a></li>
                    <li><a href="#">Member List</a></li>
                    <li><a href="#">Member Groups</a></li>
                </ul>
            </li>
            <li><a href="#">Pet Help</a></li>
            <li><a href="#">Pets for Sale</a></li>
            <li><a href="#">Pet Services</a></li>
        </ul>
    </header>
</body>
</html>

The problem with this menu in IE6 is that it's using selectors like this:

header ul#menu li:hover ul

IE6 only supports :hover on a elements.

Fortunately, there's a really easy fix to make this menu work in IE6.

It's called Whatever:hover

  • Download the (minified) csshover3.htc file.
  • Add this CSS:

    body {
        behavior: url("csshover3.htc");
    }
    

Here's a self-contained file that I tested to work with IE6, provided that the csshover3.htc file is in the same folder:

<!DOCTYPE html>
<html>
<head>
<title>Simple Tabbed Navigation - CSS3</title>
<!--[if lt IE 9]><script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script><![endif]-->
<meta charset="utf-8" />

<style>
body {
   behavior: url("csshover3.htc");
}

body
{
    background: #efefef url(images/bg_main.png);
    font: 13px Helvetica, Arial;
    margin: 0;
}

header
{
    background: url(images/bg_head.png);
    display: block; /* Compatibility fix */
}

header:after
{
    background: rgba(0, 0, 0, 0.1);
    content: ' ';
    height: 1px;
    position: absolute;
    width: 100%;
    z-index: 10;
}

header ul#menu
{
    border-bottom: 5px solid #fff;
    margin: 0;
    overflow: hidden;
    padding: 0 10px;
    padding-top: 100px;
    list-style: none
}

header ul#menu li
{
    float: left;

}

header ul#menu li a
{
    background: #b1d0dd;
    border-top: 1px solid #d0e2ea;
    color: #fff;
    font-weight: bold;
    display: block;
    line-height: 34px;
    margin-right: 2px;
    padding: 0 20px;
    text-decoration: none;
    text-shadow: 0 -1px rgba(0, 0, 0, 0.25);

    border-radius: 3px 3px 0 0; /* Currently working on Firefox 4.0b (Nightly), Chrome 8.0.xxxx and Opera 10.63+ */

    background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#B1D0DD), to(#89b8cc));
    background-image: -moz-linear-gradient(top, #B1D0DD,    #89B8CC);
}

header ul#menu li > ul
{
    display: none;
}

header ul#menu li a:hover
{
    background: #fff;
    border-top-color: #fff;
    color: #666;
    text-shadow: none;
}

header ul#menu ul {
    background: #fff;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    display: none;
    margin-left: 0;
    margin: 0;
    padding: 5px 0 0 0;
    position: absolute;
    z-index: 999;
}

header ul#menu ul li
{
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-width: 0 1px;
    float: none;
    list-style: none;
    margin: 0;
    padding: 0;
}

header ul#menu ul li a
{
    background: none;
    border-bottom: 1px solid #ededed;
    border-top: none;
    color: #666;
    font-weight: normal;
    font-size: 12px;
    margin: 0 20px;
    padding: 0;
    text-shadow: none;
    width: 118px;
}

header ul#menu li a.home-icon span
{
    background: url(images/home-icon.png) no-repeat center center;
    display: block;
    text-indent: -999em;
    overflow: hidden;
    text-align: left;
    direction: ltr;
    width: 16px;
}

header ul#menu li a.home-icon:hover span
{
    background-image: url(images/home-icon-hover.png);
}

header ul#menu ul li:last-child a
{
    border-bottom: none;
}

header ul#menu li:hover ul
{
    display: block;
}

header ul#menu ul li a:hover
{
    color: #000;
}

header ul#menu ul li:last-child
{
    border-bottom: none
}
</style>

</head>
<body>  
    <header>
        <ul id="menu">
            <li><a href="#homepage" class="home-icon"><span>Home</span></a></li>
            <li>
                <a href="#">Community</a>
                <ul>
                    <li><a href="#">Recent Activity</a></li>
                    <li><a href="#">Member Forum</a></li>
                    <li><a href="#">Member List</a></li>
                    <li><a href="#">Member Groups</a></li>
                </ul>
            </li>
            <li><a href="#">Pet Help</a></li>
            <li><a href="#">Pets for Sale</a></li>
            <li><a href="#">Pet Services</a></li>
        </ul>
    </header>
</body>
</html>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文