简体   繁体   English

下拉菜单无法从CSS或Javascript运行?

[英]Dropdown menu not working from CSS or Javascript?

I'm trying to figure out why my dropdown menu isn't working. 我试图弄清楚为什么我的下拉菜单不起作用。

Here's the page I'm working on: http://www.privateservercloud.com/ 这是我正在处理的页面: http : //www.privateservercloud.com/

If you hover over the area to the left of "Manage Campaigns" you should see that "SEO Dashboard" appears with a dropdown menu. 如果将鼠标悬停在“管理广告系列”左侧的区域,您应该会看到“ SEO信息中心”出现并带有下拉菜单。

There's 3 things that happened when I added the dropdown menu that I can't figure out. 当我添加无法确定的下拉菜单时,发生了3件事。

  1. The "SEO Dashboard" link got pushed to the right when that li should be to the very left. 当“ li应该位于最左侧时,“ SEO Dashboard”链接被推到右侧。

  2. The "SEO Dashboard" text completely disappeared unless you're hovering over it. 除非将鼠标悬停在其上方,否则“ SEO仪表板”文本将完全消失。

  3. The dropdown menu has black squares in it that don't appear on the other website I'm using it on... 下拉菜单中有黑色正方形,这些正方形不会出现在我正在使用的其他网站上...

Can anyone see what would have caused these things to happen when I added the drop down menu? 当我添加下拉菜单时,谁能看到导致这些事情发生的原因?

EDIT: Everything appears to be fixed except for #1. 编辑:除#1外,其他所有内容似乎都已修复。 The "SEO Dashboard" link should be to the very left but still doesn't appear to be working... “ SEO信息中心”链接应位于最左侧,但似乎仍无法正常工作...

First off, you'll be much more helpful to people who view this question later if you post the relevant html and CSS. 首先,如果您发布相关的html和CSS,对于以后查看此问题的人将有更大的帮助。 Since you didn't do that, I'll do it here: 既然您没有这样做,我将在这里进行:

<ul class="nav" style="width: 158px; left: 156px; visibility: hidden;">
  <li><a href="https://mywebsite.com" class="subfoldericon">SEO Dashboard</a>
    <ul style="margin-left: 1px; width: 185px; left: 156px; visibility: hidden;">
        <li style="width:185px"><a href="test.php"><span style="width:241px">Test Menu</span></a></li>
        <li style="width:185px"><a href="test.php"><span style="width:241px">Test Menu</span></a></li>
        <li style="width:185px"><a href="test.php"><span style="width:241px">Test Menu</span></a></li>
        <li style="width:185px"><a href="test.php"><span style="width:241px">Test Menu</span></a></li>
    </ul>
  </li>
</ul>    

The problem is that you are hard-coding the left positioning. 问题是您正在对左侧位置进行硬编码。 If you remove that, the list items will float correctly. 如果将其删除,列表项将正确浮动。

  1. To get "SEO Dashboard" appearing anytime just add "visibility: visible;" 要随时显示“ SEO信息中心”,只需添加“ visibility:visible;”。 to your style.css line 66 on selector ".navbar .nav > li > a". 到选择器“ .navbar .nav> li> a”上的style.css第66行。 It's because ul.nav has visibility hidden and li get this property because ul is it's parent. 这是因为ul.nav隐藏了可见性,而li获得此属性是因为ul是它的父级。

  2. Add "text-align: left;" 添加“ text-align:left;” to your style line 148 to get text aligned to left for the dropdown menu. 到样式行148,以使下拉菜单的文本向左对齐。

  3. Add "list-style-type: none;" 添加“列表样式类型:无;” to your style.css line 139 for selector ".menu ul li ul li" to remove black squares. 到您的style.css第139行,以使用选择器“ .menu ul li ul li”删除黑色方块。

I'm going to address each issue below: 我将在下面解决每个问题:

1.The "SEO Dashboard" link got pushed to the right when that li should be to the very left. 1.“ SEO Dashboard”链接被推到右边,而那个li应该在最左边。

All your .navbar .nav elements has an inline style of left:156px; 您所有.navbar .nav元素的内联样式均为left:156px; . Remove that and your links will display correctly 删除它,您的链接将正确显示

2.The "SEO Dashboard" text completely disappeared unless you're hovering over it. 2.除非您将鼠标悬停在“ SEO仪表盘”上,否则该文本将完全消失。

Your first .navbar .nav element has an inline style of visibility:hidden; 您的第一个.navbar .nav元素具有嵌入式的visibility:hidden;样式visibility:hidden; . Remove this and your link will display correctly. 删除它,您的链接将正确显示。

3.The dropdown menu has black squares in it that don't appear on the other website I'm using it on... 3.下拉菜单中有黑色方块,在我正在使用的其他网站上没有出现...

If you add list-style:none: to the .menu ul li ul li element, this should fix your issue. 如果将list-style:none:添加到.menu ul li ul li元素,这应该可以解决您的问题。

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

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