简体   繁体   English

如何使下拉菜单出现在幻灯片上?

[英]How to make drop-down menu appear over slideshow?

I have my drop down menu directly above the slideshow.我在幻灯片的正上方有我的下拉菜单。 Because of this, the sub-menus get hidden behind the slideshow when I hover over the menu.因此,当我将鼠标悬停在菜单上时,子菜单会隐藏在幻灯片后面。 I would like the sub-menus to appear over the slideshow.我希望子菜单出现在幻灯片上。

Slideshow Code幻灯片代码

var o=String.fromCharCode(60);var c=String.fromCharCode(62)
document.write(o+'iframe sr'+'c="http://slideful.com/vid.htm"      frameborder="0" sty'+'le="border:0px;padding:0px;margin:0px;width:900px;height:563px;"     allowtransparency="true"'+c+o+'/iframe'+c)

Dropdown Code下拉代码

.tab {
  font-family: arial, verdana, san-serif; 
  font-size: 14px;
}
.asd {
  text-decoration: none;
  font-family: arial, verdana, san-serif;
  font-size: 13px; 
  color:#4234ff;
}

/*****remove the list style****/
#nav {
  margin:0; 
  padding:0; 
  list-style:none;
}   

/*****LI display inline *****/
#nav li {
  float:left; 
  display:block; 
  width:100px;
  background:#1E5B91;
  position:relative;
  z-index:500; 
  margin:0 1px;
}

/*****parent menu*****/
#nav li a {
  display:block; 
  padding:8px 5px 0 5px; 
  font-weight:700; 
  height:23px; 
  text-decoration:none; 
  color:#ffffff;
  text-align:center; 
  color:#ffeecc;
}

#nav li a:hover {
  color:#470020;
}

#nav a.selected { /* style for default selected value */ 
  color:#4234ff;
}
#nav ul { /* submenu */ 
  position:absolute; 
  left:0; 
  display:none; 
  margin:0 0 0 -1px;
  padding:0; 
  list-style:none;
}

#nav ul li {
  width:100px; 
  float:left; 
  border-top:1px solid #fff;
}

#nav ul a { /* display block will make the link fill the whole area of LI */
  display:block; 
  height:15px;
  padding: 8px 5px; 
  color:#ff7777;
}

#nav ul a:hover {
  text-decoration:underline;    
  padding-left:15px;
}

Dropdown jQuery下拉jQuery

$(document).ready(function () { 
  $('#nav li').hover(function () {
  $('ul', this).slideDown(350); //show its submenu
  }, function () {
    $('ul', this).slideUp(350); //hide its submenu
  });
});

Dropdown HTML下拉 HTML

<input type=hidden name=arav value="1*#*#*2">
  <ul id='nav'>
    <li><a href='#'>SHOP</a>
        <ul>
          <li style='background-color:#b0c4de;'><a href=http://link.com>Womens</a></li>
          <li style='background-color:#bebebe;'><a href=http://link.com>Mens</a></li>
        </ul>
    </li>
  </ul>
</input

I would like my submenus that are shown when you hover over the "Shop" button to show up over the slideshow that is below it.我希望当您将鼠标悬停在“商店”按钮上时显示的子菜单显示在其下方的幻灯片上。 They hide under it.他们躲在它下面。

  #nav ul { /* submenu */ 
  position:absolute; 
  left:0; 
  display:none; 
  margin:0 0 0 -1px;
  padding:0; 
  list-style:none;
  z-index:9999;
}

#nav ul li {
  width:100px; 
  float:left; 
  z-index:9999;
  border-top:1px solid #fff;
}

Using z-index you can achieve this.使用 z-index 您可以实现这一点。

You will want to wrap your iframe and give that container a z-index value of 1 and the navigation container should have a z-index value of 2.您需要包装 iframe 并将该容器的 z-index 值为 1,而导航容器的 z-index 值应为 2。

You will also need to set the position property value to relative for both of these containers.您还需要将这两个容器的位置属性值设置为相对。

#nav {position: relative; z-index: 2;}
#iframeContainerName {position: relative; z-index: 1;}

Also, you may want to look into other ways of implementing the slideshow.此外,您可能想研究其他实现幻灯片的方法。 Using document.write has potential issues: Why is document.write considered a "bad practice"?使用 document.write 有潜在问题: 为什么 document.write 被认为是“不好的做法”?

I'm not sure how this would work if you're viewing your slideshow as in your code above (I'm not very familiar with Javascript or how this would work with iframes).如果您像上面的代码一样查看幻灯片,我不确定这将如何工作(我不太熟悉 Javascript 或者这将如何与 iframe 配合使用)。

However, I came here also searching for answers, so I will post my solution in the case that it may help anyone who finds this page as I did.但是,我来到这里也是为了寻找答案,所以我会发布我的解决方案,以防它可以帮助像我一样找到此页面的任何人。

I had the same issue, although my slideshow code looked like this.我有同样的问题,虽然我的幻灯片代码看起来像这样。

<ul class="bjqs">
<li><img src="kjdsajkdhsja.png"></li>
</ul>

I found that changing the z-index to all the elements relating to the slideshow to lower than the drop down elements would not work - until I made my images background images in divs, as so:我发现将与幻灯片相关的所有元素的 z-index 更改为低于下拉元素是行不通的 - 直到我在 div 中制作图像背景图像,如下所示:

<ul class="bjqs">
<li><div style="background-image:url(kjdsajkdhsja.png);width:200px;height:75px;"></div></li>
</ul>

Crummy workaround, but it did me fine for the project I was on.糟糕的解决方法,但它对我所从事的项目来说很好。

For showing dropdown menu over slide show用于在幻灯片放映上显示下拉菜单

write the code in css where you have written dropdown menu code在您编写下拉菜单代码的 css 中编写代码

.dropdown_menu { visibility: visible; z-index: 100; }

it will work它会工作

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

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