tes*_*ing 9 html css internet-explorer z-index css-position
我发现如果我想进入第二级菜单,主菜单中的悬停效果会消失.在这里您可以找到示例:
HTML:
<div id="background-slider">
<a href="http://www.hdwallpapersarena.com/wp-content/uploads/2012/10/Opera-Background-Blue-Swirls.jpg"></a>
<a href="http://www.hdwallpapersarena.com/wp-content/uploads/2012/10/green-abstract-background.jpg"></a>
</div>
<div id="menu">
<nav>
<ul class="nav-level-1">
<li class="level-1 clearfix">
<a href="unternehmen.html" class="level-1">Unternehmen</a>
<ul class="nav-level-2">
<li class="level-2"><a href="/unternehmen/die-firma.html" class="level-2">Die Firma</a></li>
<li class="level-2"><a href="/unternehmen/das-team.html" class="level-2">Das Team</a></li>
<li class="level-2"><a href="/unternehmen/allgemeines.html" class="level-2">Allgemeines</a></li>
</ul>
</li>
</ul>
<div class="clearer"></div>
</nav>
</div>
<div id="script-section" class="hidden">
<script src="./js/jquery.superbgimage.min.js"></script>
<script>
$(document).ready(function(){
// Options for SuperBGImage
$.fn.superbgimage.options = {
transition: 1,
speed: 'slow',
randomtransition: 0,
slideshow: 1,
slide_interval: 6000,
randomimage: 0
};
// initialize SuperBGImage
$('#background-slider').superbgimage().hide;
});
</script>
</div>
Run Code Online (Sandbox Code Playgroud)
CSS:
#menu {
position: fixed;
z-index: 4;
left: 23px;
bottom: 40px;
}
ul.nav-level-1 {
float: left;
text-align: left;
}
ul.nav-level-1 li.level-1 {
/*float: left;*/
}
ul.nav-level-1 li.level-1 a.level-1 {
font-family: 'SourceSansProBlack', Arial, sans-serif;
font-size: 36px;
line-height: 40px;
text-transform: uppercase;
text-decoration: none;
color: #123373;
padding: 0 5px;
transition: color 0.25s ease 0s, background-color 0.25s ease 0s;
float: left;
}
ul.nav-level-1 li.level-1 a.level-1:hover {
text-decoration: none;
color: #123373;
background-color: #FFF;
display: inline-block;
}
ul.nav-level-1 li:hover a {
background-color: #FFF;
}
ul.nav-level-1 li.level-1:hover ul.nav-level-2 {
display: block;
}
ul.nav-level-2 {
display: none;
float: left;
width: 390px;
padding-left: 10px;
text-align: left;
}
ul.nav-level-2 li.level-2 {
margin-bottom: 3px;
margin-right: 5px;
float: left;
}
ul.nav-level-2 li.level-2 a.level-2{
font-family: 'SourceSansProBold', Arial, sans-serif;
font-size: 14px;
line-height: 16px;
text-transform: uppercase;
text-decoration: none;
color: #123373;
padding: 0 5px;
background-color: #FFF;
transition: color 0.25s ease 0s, background-color 0.25s ease 0s;
}
ul.nav-level-2 li.level-2 a.level-2:hover{
background-color: #123373;
color: #FFF;
}
Run Code Online (Sandbox Code Playgroud)
我正在使用的滑块叫做SuperBGImage.如果我删除滑块一切正常!
我瘦它是IE的z-Index错误,但我尝试了添加position: relative;没有成功的不同选项.如何在IE中修复悬停效果?
我试过这个JS代码,但它也无济于事:
$('li.level-1').hover(function() {
$(this).children('ul.nav-level-2').removeClass('hidden');
$(this).children('ul.nav-level-2').addClass('visible');
});
$('ul.nav-level-2').mouseout(function() {
$(this).removeClass('visible');
$(this).addClass('hidden');
});
Run Code Online (Sandbox Code Playgroud)
也许这是一个浮动问题.如果我删除float: left;它比它更好,但它不是它应该是的设计.
编辑:
在这里,您可以下载该项目.我注意到了另一件事.如果我启动Internet Explorer,他会问我是否要启动脚本或Active-X元素.他为什么问我这个?我知道这是因为滑块但它应该是正常的Javascript.或许来自滑块的JS在这里做了一些特别的事......
我已经在IE9和IE10上工作也应该在IE8中工作,使用透明背景并将鼠标悬停在上面.clearfix
看看更新的 - jsFiddle
我改变了这个 -
ul.nav-level-1 li.level-1 a.level-1:hover {
text-decoration: none;
color: #123373;
background-color: #FFF;
display: inline-block;
}
Run Code Online (Sandbox Code Playgroud)
对此 -
.clearfix:hover ul.nav-level-1, li.level-1, a.level-1{
text-decoration: none;
color: #123373;
background: rgba(0, 0, 0, 0.0); /*** TRANSPARENT BACKGROUND FIX ***/
display: inline-block;
}
Run Code Online (Sandbox Code Playgroud)
并为此增加了高度和宽度 -
.clearfix {
display:block;
width:100%; /* added height and width */
height:50px;
}
Run Code Online (Sandbox Code Playgroud)
对于IE7及以下添加 -
<!--[if lte IE 7]>
<style type="text/css">
.clearfix:hover ul.nav-level-1, li.level-1, a.level-1 {
text-decoration: none;
color: #123373;
background:#ffffff;
display: inline-block;
}
</style>
<![endif]-->
Run Code Online (Sandbox Code Playgroud)
上面的工作只是用透明的白色替换透明的rgba.它在古代IE中不会那么漂亮,但很少有东西.
请注意,<nav>IE8及以下版本不支持此功能
CedricReichenbach 给我带来了另一个想法。添加透明背景图像(1x1)似乎适用于 IE:
.level-1 ul {
background-image: url(../img/transparent-background.png);
background-repeat: repeat;
}
Run Code Online (Sandbox Code Playgroud)
虽然会进行更多测试。
| 归档时间: |
|
| 查看次数: |
970 次 |
| 最近记录: |