简体   繁体   English

CSS下拉菜单-重叠元素

[英]CSS drop down menu - overlapping elements

I've made a drop-down menu but when I hover over a parent category, the children appear crowded and overlapping. 我做了一个下拉菜单,但是当我将鼠标悬停在父类别上时,孩子显得拥挤而重叠。 It seems the children 'elements' are not being placed neatly one below the other; 似乎孩子的“元素”没有被整齐地放置在另一个之下。 rather, they overlap each other. 相反,它们彼此重叠。

I've tried fixing it myself and looking at google and here, but I didn't find any solution that solves this issue. 我已经尝试自己修复此问题,并在Google和此处查看,但没有找到解决此问题的解决方案。 I've also read "Inline elements and padding" guide, but it didn't help me. 我还阅读了“内联元素和填充”指南,但对我没有帮助。 I'm not a programmer, I'm just doing some customizing of a purchased theme ( http://meros11.gostorego.com/ ). 我不是程序员,我只是对购买的主题( http://meros11.gostorego.com/ )进行一些自定义。

Any help would be appreciated. 任何帮助,将不胜感激。

Do I need to post all my code, or can you see it yourself using the developer tools? 我需要发布所有代码,还是可以使用开发人员工具自己查看代码? (such as in Chrome) (例如在Chrome中)

Thanks! 谢谢!

The issue is with this class, which is applying to all of the menu elements: 这个类存在问题,该类适用于所有菜单元素:

#nav li.parent a span {
    margin-top: -10px;  /* This is what's making them crowded */
}

Looking at the style of your nav menu, this style should only apply to the top level li elements (Example Category, Family Tree, Marriages), but it is applying to all of your a elements. 查看导航菜单的样式,此样式应仅适用于顶层li元素(示例类别,族谱,婚姻),但它适用于所有a元素。

I would change the name of this id to a class (remove the "#nav li.parent a span" and replace with ".[your class name here]" then apply that class to the top level li elements (Example Category, Family Tree, Marriages). 我会将这个id的名称更改为一个class (删除“ #nav li.parent a span”并替换为“。[此处是您的类名称]”,然后将该类应用于顶级li元素(例如Category,Family树,婚姻)。

Change 更改

<li class="level0 nav-1 level-top first parent hasProducts">

to

<li class="level0 nav-1 level-top first parent hasProducts [YOUR CLASS HERE]">

Then in your CSS: 然后在您的CSS中:

change 更改

#nav li.parent a span {
    margin-top: -10px;
}

to

.[YOUR CLASS HERE]{
    margin-top:-10px;
}

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

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