菜单悬停效果在IE中不起作用

时间:2014-01-01 04:14:35

标签: jquery asp.net css internet-explorer menu

我正在处理我使用悬停菜单的项目。哪个在Chrome和FF中运行良好。但现在在IE7和IE8中工作。此菜单动态绑定到表单。如下图所示。

enter image description here

您看到的任何菜单效果都在Chrome内部发生。但不是在IE中,如下所示。

enter image description here

我的CSS文件如下。

/* reset  list style */
.cbp-tm-menu,
.cbp-tm-menu ul {
    list-style: none;
}

/* set menu position; change here to set to relative or float, etc. */
.cbp-tm-menu {
    font-family: "Bebas Neue";
    font-size: 16px;
    color: #FFFFFF;
    text-decoration: none;
    text-transform: uppercase;
    background-color:#2b343b;
    margin:0;

}

/* first level menu items */
.cbp-tm-menu > li {
    display: inline-block;
    position: relative;
    padding-left:21px;

}

.cbp-tm-menu > li > a {
    line-height: 3em;
    padding-right:1em;
    font-size: 23px;
    display: block;
    color: #fff;

}

.no-touch .cbp-tm-menu > li > a:hover,
.no-touch .cbp-tm-menu > li > a:active {
    color: #e82c5c;
}

/* sumbenu with transitions */
.cbp-tm-submenu {
    position: absolute;

    visibility: hidden;
    opacity: 0;
    padding: 0;
    text-align: left;
    pointer-events: none;
    -webkit-transition: visibility 0s, opacity 0s;
    -moz-transition: visibility 0s, opacity 0s;
    transition: visibility 0s, opacity 0s;

}

.cbp-tm-show .cbp-tm-submenu {
    width: 10em;
    left: 30%;
    margin: 0 0 0 -8em;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    -webkit-transition: visibility 0s, opacity 0.3s;
    -moz-transition: visibility 0s, opacity 0.3s;
    transition: visibility 0s, opacity 0.3s;
}

.cbp-tm-show-above .cbp-tm-submenu {
    bottom: 100%;
    padding-bottom: 10px;
}

.cbp-tm-show-below .cbp-tm-submenu {
    top: 100%;
    padding-top: 10px;
}
.cbp-tm-menu > li:hover
{
    background-color: Gray;

}


/* extreme cases: not enough space on the sides */
.cbp-tm-nospace-right .cbp-tm-submenu {
    right: 0;
    left: auto;
}

.cbp-tm-nospace-left .cbp-tm-submenu {
    left: 0;
}

/* last menu item has to fit on the screen */
.cbp-tm-menu > li:last-child .cbp-tm-submenu {
    /*right: 0;*/
}

/*  
arrow: depending on where the menu will be shown, we set 
the right position for the arrow
*/

.cbp-tm-submenu span {
    border: solid transparent;
    content: " ";
    height: 0;
    width: 0;
    position: absolute;

}
.cbp-tm-show-above .cbp-tm-submenu span{
    border-top-color: #fff;
}

.cbp-tm-show-below .cbp-tm-submenu span{
    border-bottom-color: #fff;
}
.cbp-tm-show-above .cbp-tm-submenu span {
    top: 100%;
    margin-top: -10px;
}

.cbp-tm-show-below .cbp-tm-submenu span {
    bottom: 100%;
    margin-bottom: -10px;
}
.cbp-tm-submenu span {
    border-color: transparent;
    border-width: 16px;
    margin-left: -26px;
    left: 64px;
}

.cbp-tm-submenu > li {
    display: block;
    background: #fff;
}
.cbp-tm-submenu > li > a {
    padding: 5px 0px 5px 0.6em; /* top/bottom paddings in 'em' cause a tiny "jump" in Chrome on Win */
    display: block;
    font-size: 16px;
    position: relative;
    color: #e82c5c;

    -webkit-transition: all 0.2s;
    -moz-transition: all 0.2s;
    transition: all 0.2s;
}

.no-touch .cbp-tm-submenu > li > a:hover,
.no-touch .cbp-tm-submenu > li > a:active {
    color: #fff;
    background: #e82c5c;
}
/* the icons (main level menu icon and sublevel icons) */
.cbp-tm-submenu li a:before,
.cbp-tm-menu > li > a:before {
    speak: none;
font-style: normal;
font-weight: normal;
font-variant: normal;
text-transform: none;
line-height: 1;
vertical-align: middle;
margin-right: 0.6em;
-webkit-font-smoothing: antialiased;
 }

 .cbp-tm-submenu li a:before {
position: absolute;
top: 50%;
margin-top: -0.5em;

}
.cbp-tm-menu > li > a:not(:only-child):before {
    opacity: 0.3;
 }


/* Media Queries */
@media screen and (max-width: 55.6875em) {
.cbp-tm-menu {
    font-size: 80%;
}
}

 @media screen and (max-height: 25.25em), screen and (max-width: 44.3125em) {

.cbp-tm-menu {
    font-size: 100%;
    position: relative;
    text-align: center;
    padding: 0;
    top: auto;
}

.cbp-tm-menu > li {
    display: block;
    margin: 0;
    border-bottom: 4px solid #000;
}

.cbp-tm-menu > li:first-child {
    border-top: 4px solid #000;
}

li.cbp-tm-show > a,
.no-touch .cbp-tm-menu > li > a:hover,
.no-touch .cbp-tm-menu > li > a:active {
    color: #fff;
    background: #000;
}

.cbp-tm-submenu {
    position: relative;
    display: none;
    width: 100%;

}

.cbp-tm-submenu > li {
    padding: 0;
}

.cbp-tm-submenu > li > a {
    padding: 0.6em 2.3em 0.6em 0.6em;
    border: none;
    border-bottom: 2px solid #000;
}

.cbp-tm-submenu:after {
    display: none;
}

.cbp-tm-menu .cbp-tm-show .cbp-tm-submenu {
    display: block;
    width: 100%;
    left: 0;
    margin: 0;
    padding: 0;
}

}

这是我的http://jsbin.com/eyUjUHET/4/

3 个答案:

答案 0 :(得分:0)

您缺少IE的CSS渲染引擎。不同的浏览器有不同的渲染引擎。

  1. Chrome -webkit
  2. Firefox -moz
  3. Opera-据我所知,opera已经切换到开源-webkit渲染引擎。
  4. Internet Explorer。我认为Internet Explorer使用Trident渲染引擎。
  5. -webkit-transition:visibility 0s,opacity 0.3s;

    -moz-transition:visibility 0s,opacity 0.3s;

    您应该在CSS中使用Trident Engine,就像使用webkit引擎进行chrome一样。

答案 1 :(得分:0)

对于< = IE9,您必须使用JavaScript进行动画处理。

jQuery提供$().animate()。要在现代浏览器中保持CSS过渡以获得最佳性能,您可以使用conditional comments仅包含在浏览器为IE9或更低版本时调用animate()的脚本。

答案 2 :(得分:0)

我知道的最简单的方法如下:

<!--[if lt IE 9]>
    <script type="text/javascript" src="js/html5shiv.min.js"></script>
    <script type="text/javascript" src="js/selectivizr.min.js"></script>       
<![endif]-->

您可以从以下网址获取脚本:

它们总是派上用场,即使IE6最终支持HTML5和CSS3:D