简体   繁体   English

Pure CSS3 LavaLamp选项卡菜单中的问题悬停

[英]Issue in Pure CSS3 LavaLamp Tab menu Hover

I implemented the Lavalamp tab menu in my website: when Mouse goes on absolute Div "#lavalamp" bottom "subs" div not display.How to fixed this, please help me. 我在我的网站上实现了Lavalamp选项卡菜单:当鼠标进入绝对Div“#lavalamp”底部“subs”div不显示时。如何修复此问题,请帮助我。

Detail code click here 详细代码请点击这里

<ul id="nav">
<li><a class="hsubs" href="#">Magento</a>
    <div class="subs colbg01">
        Submenu 1
    </div>
</li>

<li><a class="hsubs" href="#">Wordpress</a>
    <div class="subs colbg02">
        Submenu 2
    </div>
</li>

<li><a class="hsubs" href="#">Mobile App</a>
    <div class="subs colbg03">
        Submenu 3
    </div>    
</li>
<div id="lavalamp"></div>

在此输入图像描述

在此输入图像描述

The problem happens when you hover over the triangle, which causes the underlining li to lose its own hover and thus invalidating the active li:nth-child(..) ~ #lavalamp rule. 当您将鼠标悬停在三角形上时会出现问题,这会导致下划线li失去自己的悬停,从而使活动的li:nth-child(..) ~ #lavalamp规则li:nth-child(..) ~ #lavalamp

You can solve this issue with modern browsers by disabling the pointer events on the lavalamp element 您可以通过禁用lavalamp元素上的指针事件来解决现代浏览器的这个问题

#lavalamp{pointer-events:none;}

demo at http://jsfiddle.net/gaby/6Lmgkhxd/4/ http://jsfiddle.net/gaby/6Lmgkhxd/4/上的演示


Notice : IE added support for pointer-events on v11 注意 :IE在v11上添加了对pointer-events支持

The reason this is not working is because the hover state of the li is being broken when hovering over the #lavalamp element (which appears later in the DOM). 这不起作用的原因是因为当悬停在#lavalamp元素(稍后出现在DOM中)时,li的悬停状态被破坏。

If you really want a CSS only fix you can use z-index to place the triangle behind everything else and bring the li forward. 如果你真的想要一个CSS修复,你可以使用z-index将三角形放在其他所有东西之后,让li向前推进。

like: 喜欢:

#nav li {
    float: left;
    display: block;
    padding: 16px 20px 18px 20px;
    z-index: 1; // <--- added this
}

#lavalamp {
    z-index: -1; // add this
    ... other code
}

example: http://jsfiddle.net/6Lmgkhxd/3/ 例如: http//jsfiddle.net/6Lmgkhxd/3/

I changed the li's background-color to transparent to allow this to work. 我将li的背景颜色更改为透明以允许它工作。

Also there seems to be a slight gap between the li and the .subs so I increased the bottom padding of the li to overlap better to the 50px top positioned .subs (from 16px to 18px ) 此外,li和.subs之间似乎存在微小的差距所以我增加了li的底部填充以更好地重叠到50px顶部定位.subs (从16px18px

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM