【问题标题】:Menu hover effect is not working in IE菜单悬停效果在 IE 中不起作用
【发布时间】:2014-01-18 20:52:21
【问题描述】:

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

您看到的任何菜单效果都在 Chrome 中发生。但在 IE 中不行,如下图。

我的 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/

【问题讨论】:

  • 如果您还没有解决问题,请发布站点链接或找我们来帮助您。这将有助于调试。
  • @Kirk- 我已经动态绑定了它......
  • @Kirk- 看看 jsfiddle...我已经更新了它
  • Chrome 上也没有显示下拉菜单?
  • @nop 它也在 chrome 中显示它......我上传了错误的 js....

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


【解决方案1】:

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

  1. Chrome -webkit
  2. 火狐-moz
  3. Opera -据我所知,Opera 已经切换到开源的-webkit 渲染引擎。
  4. Internet Explorer。我认为 Internet Explorer 使用 Trident 渲染引擎。

-webkit-transition:可见性0s,不透明度0.3s;

-moz-transition:可见度0s,不透明度0.3s;

你应该在你的 CSS 中使用 Trident 引擎,就像你在 chrome 中使用 webkit 引擎一样。

【讨论】:

  • 我认为 Internet Explorer 9 及更早的版本不支持过渡属性。
  • 它的 IE8 .. 我通过这个链接知道了...caniuse.com/css-transitions 还有其他方法可以使用它吗?
【解决方案2】:

对于

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

【讨论】:

  • 我刚刚注意到我在回答“这需要在 IE7 和 IE8 中进行动画处理”,而不是“这需要显示”的实际问题。对此我很抱歉。您能否发布站点链接或创建一个 jsfiddle,以便我们帮助您调试它?
【解决方案3】:

对于这种情况,我知道的最简单的方法如下:

<!--[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

【讨论】:

  • 我已经做到了...我已经制作了一个名为 ie.css 的 css...如果它的 IE 那么它将适用于该 css...
猜你喜欢
  • 2015-08-08
  • 1970-01-01
  • 2021-04-12
  • 2011-07-29
  • 1970-01-01
  • 1970-01-01
  • 2012-06-05
  • 1970-01-01
  • 2016-11-27
相关资源
最近更新 更多