简体   繁体   English

下拉导航CSS问题

[英]Dropdown Navigation CSS Issue

new to this board, please bear with me. 新手,请耐心等待。

I've seen a lot of similar threads to my issue but I still can't find a solution so I decided to see if I could get some help here. 我已经看到了很多与我的问题类似的线索,但仍然找不到解决方案,因此我决定看看是否可以在这里获得帮助。

The majority of the code was done by someone else -- I'm not a coder / developer by any means so I'm basically doing damage control with my limited knowledge. 大部分代码是由其他人完成的-我无论如何都不是编码员/开发人员,所以我基本上是在有限的知识下进行损害控制。 If you look at the CSS you'll see that the guy did a sloppy job. 如果您查看CSS,您会发现这家伙做得很草率。

Here's a link to one of the pages: http://bumbu.com/recipes.php -- but the issue applies to the whole site. 这是其中一个页面的链接: http : //bumbu.com/recipes.php ,但是问题只适用于整个网站。 It is regarding the navigation, and is in the style.css (line 108-231) (possibly the header html as well) 它与导航有关,位于style.css(第108-231行)中(可能还有html标题)

Issues: 问题:

  1. There are two dropdowns - one under 'the Blend' and one under 'Cocktails', when you mouse on the Blend dropdown and mouse away the dropdown glitchily appears on the left side of the screen and is overlapping somehow. 有两个下拉菜单-在“ Blend”下的一个下拉菜单和在“ Cocktails”下的一个下拉菜单,当您在Blend下拉列表上单击鼠标并移开鼠标时,下拉菜单会出现在屏幕左侧,并且以某种方式重叠。

  2. The whole navigation is positioned using a really stupid system of margin-lefts and padding on multiple classes and when I change one thing it messes up the other. 整个导航使用真正愚蠢的左边距制和多个类的填充进行定位,当我更改一件事时,它会使另一件事弄乱。 You can see that the dropdown on Cocktails isn't positioned perfectly to the link and the yellow bar hover state. 您会看到Cocktails上的下拉列表与链接和黄色条形悬停状态的位置并不完美。

  3. There are also some really stupid breakpoints (around 1025px and 990px) that you'll see are also messing up the dropdowns to the point you cant even click the dropdown links. 还有一些非常愚蠢的断点(大约1025像素和990像素)也会使下拉列表混乱,甚至无法单击下拉链接。 When I give new CSS to the breakpoint it messes up the desktop state and vice versa. 当我给断点添加新CSS时,它会使桌面状态混乱,反之亦然。

I've tried messing with all the different navigation and drop down CSS by trial and error and when I get one thing right something else messes up. 我试过弄乱所有不同的导航,并通过试错法将CSS下拉,当我正确处理一件事时,其他东西就会混乱。 Since the site looks good to me otherwise I don't really want to re do all the code for the nav from scratch. 由于该网站对我来说看起来不错,否则我真的不想从头开始为导航进行所有代码。 Any help would be useful. 任何帮助将是有用的。 Thanks in advance!! 提前致谢!! If there's more info I can give that can help let me know. 如果有更多信息,我可以提供,可以帮助我知道。

Screenshot of the issue: 问题的屏幕截图:


(source: bumbu.com ) (来源: bumbu.com

I don't know why the developer has used margins for alignment, which is a worst practice. 我不知道为什么开发人员使用边距进行对齐,这是最糟糕的做法。 But this fixes it: 但这解决了:

.sub-nav2 {
  transition: opacity 0.4s ease-out;
  position: absolute;
  text-align: left;
  margin-left: -108px; /* Change this here. */
  margin-top: 90px;
}

You may need to do some tweaking with the 108px . 您可能需要对108px进行一些调整。 What I see is: 我看到的是:

Solution for Skipping 跳过解决方案

/* Line #185 */
nav ul ul {
  padding-top: 5px;
  margin-top: 85px;
}
/* Line #195 */
.sub-nav2 {
  margin-left: -108px;
  margin-top: 85px;
}

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

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