简体   繁体   English

在 android 的 chrome 中的视频元素上时下拉导航栏不可点击

[英]Dropdown navbar unclickable when over video element in chrome for android

I have a dropdown navbar with position: sticky and i have a video element .我有一个带有position: sticky下拉导航栏,我有一个视频元素 When scrolling down in landscape mode the navbar should overlay the video, and it does, but the default play button is still displayed over the navbar, and regardless of that, the navbar links are not clickable when they appear over the video element.在横向模式下向下滚动时,导航栏应该覆盖视频,并且确实如此,但默认播放按钮仍显示在导航栏上,无论如何,当导航栏链接出现在视频元素上时,它们是不可点击的。 It works fine on other browsers.它在其他浏览器上运行良好。

I found some suggestions that using z-index might help but the issue stayed我发现了一些使用z-index可能会有所帮助的建议,但问题仍然存在

Heres's some example:下面是一些例子:

 nav ul { list-style-type: none; margin: 0; background-color: #480607; overflow: hidden; width: 100%; } nav ul li { float: left; } nav ul li a { color: white; padding: 20px 40px; text-decoration: none; display: block; } nav ul li a.active { background-color: #160000; } nav ul li a:hover:not(.active) { background-color: #4f4f4f; } h1 { margin: 2px; } header { text-align: center; background-color: #160000; margin: -2px; align-self: start; color: white; } #sticky{ position: sticky; top: 0; z-index: 1; } nav { align-self: start; } nav img { display: none; } video{ z-index: 0; } /*smartphone*/ @media screen and (max-width: 600px) and (orientation: portrait) { ul { display: none; } nav img { display: block; width: 30px; position: fixed; top: 0; } nav:hover ul { display: block; } main { grid-template-columns: 1fr; grid-template-areas: 'greeting' 'text' 'media'; } iframe, video { width: 70vw; height: 39.354vw; } }
 <div id="sticky"> <header> <h1>some header</h1> </header> <nav> <img id="menu_icon" src="media/menu.png" alt="menu icon" /> <ul> <li><a class="active" href="index.html">first</a></li> <li><a href="tortenet.html">second</a></li> <li><a href="targyak.html">third</a></li> <li><a href="elovilag.html">fourth</a></li> </ul> </nav> </div> <main> <section id="media"> <figure> <video width="560" controls="controls"> <source src="media/short_gameplay.mp4" type="video/mp4" /> Nem működik a lejátszó? <a href="media/short_gameplay.mp4">töltsd le a videót</a> </video> <figcaption>Az első lépések</figcaption> </figure> </section> </main>

Thank you for reading trough all this!感谢您阅读所有这些内容!

After all z-index was the solution, but as @CBroe stated it only works with position: relative .毕竟z-index是解决方案,但正如@CBroe所说,它仅适用于position: relative So the correct css would be like this所以正确的 css 应该是这样的

video{
    position: relative;
    z-index: 0;
}
#sticky{
    position: sticky;
    top: 0;
    z-index: 1;
}

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

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