简体   繁体   English

单击下拉菜单时,它并不完全可见

[英]Dropdown menu when clicked it's not completely visible

I'm making a custom website with a simple mobile menu for now. 我现在正在使用简单的移动菜单制作自定义网站。

In the homepage, it's all ok. 在首页上,一切正常。 In the other pages, I have some modifies which compromise the operation of the menu. 在其他页面中,我进行了一些修改,这些修改会损害菜单的操作。 It remains under the content when clicked the collection dropdown menu. 单击集合下拉菜单时,它仍保留在内容下。

I'm trying to use different third parties menu but the issue still persists. 我正在尝试使用其他第三方菜单,但问题仍然存在。

<ul class="main-nav page-nav">
  <li><a href="../index.html">Home</a></li>
  <li><a href="#">Bio</a></li>
  <li>
    <div class="dropdown">
      <button class="dropbtn"><a href="collection.html">Collection</a></button>
      <div class="dropdown-content">
        <a href="#">Human</a>
        <a href="#">Dog</a>
        <a href="#">Accessories</a>
      </div>
    </div>
  </li>
  <li><a href="#">Social Wall</a></li>
  <li><a href="#">Contacts</a></li>
</ul>

I need to have the menu over the content totally visible when I pass the mouse hover collection. 当我通过鼠标悬停集合时,我需要使内容菜单完全可见。

the content of .dropdown-content is limited by the height of .page-header and it would not be fixed by increasing the z-index of .dropdown-content. .dropdown-content的内容受.page-header的高度限制,并且不能通过增加.dropdown-content的z-index来固定。

So from dev tools I increased the height of .page-header from 25vh to 30vh and it shows the content of .dropdown-content, so you may want to do so 因此,通过开发工具,我将.page-header的高度从25vh增加到30vh,它显示了.dropdown-content的内容,因此您可能想要这样做

.page-header {
  height: 30vh;
}

Your header element has a fixed height and the overflow property set to hidden . 您的header元素具有固定的高度,并且overflow属性设置为hidden Therefore, anything that exceeds the bounds of the element will be cropped out. 因此,超出元素范围的所有内容都会被裁剪掉。

You can fix this by either: 您可以通过以下任一方法解决此问题:

header{
    overflow: hidden; /* removing this */
}

Or making the dropdown content fixed: 或固定下拉列表内容:

.dropdown-content{
    position: fixed; /* (i'd suggest this one) as you may need to have
                     no overflow on your header element */
}

I suggest you add your css aswell. 我建议您也添加CSS。 I am also guessing you are using a framework based on the classnames. 我还猜测您正在使用基于类名的框架。

Add this info to your question in order to get an efficient response. 将此信息添加到您的问题中以获得有效的答复。

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

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