jquery - CSS Accordion 菜单,在 IE Quirks 模式下不起作用

标签 jquery css internet-explorer menu accordion

这是我正在使用的:

<style>
    html {
  background:#4d4d4d;
}

#accordion .item {
    width: 194px;
    max-height: 33px;
    background:lightsalmon;
    overflow: hidden;
    margin-bottom:5px;
    transition: max-height .5s;
    -o-transition: max-height .5s;
    -moz-transition: max-height .5s;
    -webkit-transition: max-height .5s;
}

#accordion a {
    display:block;
    height:auto;
    width:184px;
    line-height:33px;
    padding-left:10px;
    color:#000000;
    text-decoration:none;
    font-weight: bold;
}

#accordion .item:hover {
    max-height:396px; /* Set to height of the longest sub-menu for best results */
}

#accordion .item a:hover {
    background:#FF3333;
    -o-transition: .3s;
    -ms-transition: .3s;
    -moz-transition: .3s;
    -webkit-transition: .3s;
    transition: .3s;
}


#accordion .item:hover {
    max-height:396px; /* Set to height of the longest sub-menu for best results */
}

.sub {
    *padding-left:20px !important;
    *overflow:hidden;
    background:#ffffff;
    color:#000000;
    *height:auto !important;
    font-weight:normal !important;
}

</style>

<div id="accordion">
    <div class="item" id="brakes">
    <a href="#">Menu 1</a>
        <a href="#" class="sub">Submenu 1</a>
        <a href="#" class="sub">Submenu 2</a>
        <a href="#" class="sub">Submenu 3</a>
        <a href="#" class="sub">Submenu 4</a>
        <a href="#" class="sub">Submenu 5</a>
        <a href="#" class="sub">Submenu 6</a>
        <a href="#" class="sub">Submenu 7</a>
    </div>
</div>

问题是它在 IE Quirks 模式下不起作用,我需要它在 quirks 下工作,因为 eBay 产品列表的工作方式。

我以为我可以使用 jQuery 设置 css,但它似乎不起作用,这是我的尝试:

<script>
    $('.item').hover(function(){
        $(this).css('max-height','396px');
    });
</script>

知道我做错了什么吗?或者更好的解决方案?

最佳答案

您正在使用过渡,这是一个 CSS3 元素,仅在 IE10 中受支持...

您需要使用外部库,例如 Modernizr , 它检测并添加某些浏览器中缺少的功能...

另见 here解决方法...

关于jquery - CSS Accordion 菜单,在 IE Quirks 模式下不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22484597/

相关文章:

jquery - 从下到上增长/显示图像

javascript - 像桌面应用程序一样调整 div 大小

html - 从 css 下拉菜单的顶部元素中删除链接和样式

html - Internet Explorer 10 渐变问题

javascript - 在 asp.net 中无法看到 JSColor 对象中的颜色面板

javascript - 防止 Colorbox 内输入元素上的 Enter 键(KeyCode 13)关闭 colorbox

java - 关闭 IE 8 兼容模式

javascript - 我们可以在 jquery-ajax 中成功调用两个或多个函数吗

javascript - 如何识别当前打开的每个单独的浏览器窗口?

javascript - 如何替换 jQuery Mobile 中已弃用的函数 - updateHash