Specifically on IE9 only, my navigation menu is sitting behind my iframe when viewing a PDF through that iFrame.
I have set up a jsfiddle to demonstrate:
http://jsfiddle.net/q6fmv/
Alternatively please see the bottom of this question for the code.
When viewed on IE9 if you hover over the navigation elements, the ones that have a sub nav you can see are hidden behind the iFrame.
I have tried setting the z-index of the nav menu to be higher than that of the iFrame but it didnt work.
How can I resolve this so the sub menu of the navigatino menu appears on top of the iframe?
HTML
<div id="navMenu">
<ul id="menu">
<li>
Menu 1
</li>
<li>Menu 2
<ul class="sub-menu">
<li>
Sub Menu 1
</li>
<li>
Sub Menu 2
</li>
<li>
Sub Menu 3
</li>
<li>
Sub Menu 4
</li>
</ul>
</li>
<li>Menu 3
</li>
<li>Menu 4
<ul class="sub-menu">
<li>
Sub Menu 1
</li>
<li>
Sub Menu 2
</li>
<li>
Sub Menu 3
</li>
<li>
Sub Menu 4
</li>
</ul>
</li>
<li>
Menu 5
</li>
</ul>
</div>
<br />
<div id="iframe">
<iframe name="myiFrame" width="100%" height="100%" title="My iFrame" id="myIframe" src="http://www.education.gov.yk.ca/pdf/pdf-test.pdf" frameBorder="0"/>
</div>
CSS
/*Initialize*/
ul#menu, ul#menu ul.sub-menu {
padding:0;
margin: 0;
}
ul#menu li, ul#menu ul.sub-menu li {
list-style-type: none;
display: inline-block;
}
/*Link Appearance*/
ul#menu li a, ul#menu li ul.sub-menu li a {
text-decoration: none;
color: #fff;
background: #666;
padding: 5px;
display:inline-block;
}
/*Make the parent of sub-menu relative*/
ul#menu li {
position: relative;
}
/*sub menu*/
ul#menu li ul.sub-menu {
display:none;
position: absolute;
top: 30px;
left: 0;
width: 100px;
}
ul#menu li:hover ul.sub-menu {
display:block;
}
Have also tried using PDFObject.js http://jsfiddle.net/q6fmv/10/. It didnt work
Have you tried the empty iframe technique ?
It was not working before because you need to add an empty iframe inside each submenu ul tag.
HTML
<div id="outer">
<div id="inner">
<div id="navMenu">
<ul id="menu">
<li>
Menu 1
</li>
<li>Menu 2
<ul class="sub-menu">
<iframe class="cover" src="about:blank"></iframe>
<li>
Sub Menu 1
</li>
<li>
Sub Menu 2
</li>
<li>
Sub Menu 3
</li>
<li>
Sub Menu 4
</li>
</ul>
</li>
<li>Menu 3
</li>
<li>Menu 4
<ul class="sub-menu">
<iframe class="cover" src="about:blank"></iframe>
<li>
Sub Menu 1
</li>
<li>
Sub Menu 2
</li>
<li>
Sub Menu 3
</li>
<li>
Sub Menu 4
</li>
</ul>
</li>
<li>
Menu 5
</li>
</ul>
</div>
CSS
#outer {
position: relative;
left:0;
top: 0;
width: 100%;
z-index: 3;
}
#inner{
background: red;
}
.cover {
position: absolute;
border: none;
top: 0;
left: 0;
width: 100%;
z-index: -2;
height:100%;
}
#pdf {
position: relative;
top:0;
z-index: 1;
}
ul#menu, ul#menu ul.sub-menu {
padding:0;
margin: 0;
z-index:3;
}
ul#menu li, ul#menu ul.sub-menu li {
list-style-type: none;
display: inline-block;
}
/*Link Appearance*/
ul#menu li a, ul#menu li ul.sub-menu li a {
text-decoration: none;
color: #fff;
background: #666;
padding: 5px;
display:inline-block;
}
/*Make the parent of sub-menu relative*/
ul#menu li {
position: relative;
}
/*sub menu*/
ul#menu li ul.sub-menu {
display:none;
position: absolute;
top: 30px;
left: 0;
width: 100px;
z-index:3;
}
ul#menu li:hover ul.sub-menu {
display:block;
position:absolute;
z-index:3;
}
EXAMPLE
http://jsfiddle.net/gDuCE/701/
I have used google docs code for embedding via iframe to the website.
I have added jsfiddle link which you can directly check in ie9.
JSFiddle code
JSFiddle fullscreen code - check this directly in ie9
If you are using google documents as iframe, then please do make sure that it is shared publicly.
<div id="navMenu">
<ul id="menu">
<li>
Menu 1
</li>
<li>Menu 2
<ul class="sub-menu">
<li>
Sub Menu 1
</li>
<li>
Sub Menu 2
</li>
<li>
Sub Menu 3
</li>
<li>
Sub Menu 4
</li>
</ul>
</li>
<li>Menu 3
</li>
<li>Menu 4
<ul class="sub-menu">
<li>
Sub Menu 1
</li>
<li>
Sub Menu 2
</li>
<li>
Sub Menu 3
</li>
<li>
Sub Menu 4
</li>
</ul>
</li>
<li>
Menu 5
</li>
</ul>
</div>
<br />
<div id="iframe">
<!--<iframe name="myiFrame" width="100%" height="100%" title="My iFrame" id="myIframe" src="http://www.education.gov.yk.ca/pdf/pdf-test.pdf" frameBorder="0"/>-->
<iframe src="https://docs.google.com/file/d/0ByF4RjDx3q6sMW9DWHR0MXNtN0k/preview" width="100%" height="100%"></iframe>
</div>
Regards D.
Try adding position and z-index to #menu or #navMenu as such
ul#menu {
position: relative;
z-index: 9999;
}
http://jsfiddle.net/q6fmv/7/
I don't have IE9 to check though
Related
I'm a beginner in web developing, when I hover my mouse to the list of my menus the dropdown menu keeps on showing in every menu. What seems to be the problem?
I tried removing the so I can use "ul li ul li" directly in css but it doesn't work and also when I try ".site-header nav ul li:hover .sub-menu-about" there is no output but ".site-header nav ul:hover .sub-menu-about" I've got the same problem even when I use ".site-header ul:hover .sub-menu-about" still the same problem.
Here is my CSS code
.sub-menu-about{
display: none;
}
.site-header ul:hover .sub-menu-about {
display: block;
margin-top: 15px;
margin-left: -15px;
position: absolute;
}
.main-navigation ul:hover .sub-menu-about ul{
display: block;
margin: 10px;
}
and this is my html code
<div class="site-header__menu group">
<nav class="main-navigation">
<ul>
<li>Home</li>
<li>About</li>
<div class="sub-menu-about">
<ul>
<li><a href="#">History</li>
<li><a href="#">Vision</li>
<li><a href="#">Mission</li>
</ul>
</div>
<li>News</li>
<li>Events</li>
</ul>
</nav>
</div>
Once I hover on the about menu, a dropdown list of History, Mission, Vision will be shown. and when I hover on different menus there will be no dropdown menu will be shown
Error No. 1: The submenu should be located inside the <li> tag. Corrected
Error No. 2:
First, you hide the class .sub-menu-about through displays: none, and then you try to show not this class itself, but a list inside it. Corrected
Result
.sub-menu-about {
display: none;
}
.site-header ul:hover .sub-menu-about {
display: block;
margin-top: 15px;
margin-left: -15px;
position: absolute;
}
.main-navigation li:hover .sub-menu-about {
display: block;
margin: 10px;
}
<div class="site-header__menu group">
<nav class="main-navigation">
<ul>
<li>Home</li>
<li>About
<div class="sub-menu-about">
<ul>
<li><a href="#">History</li>
<li><a href="#">Vision</li>
<li><a href="#">Mission</li>
</ul>
</div>
</li>
<li>News</li>
<li>Events</li>
</ul>
</nav>
</div>
I have a problem. I can't crate my droppable menu.
https://probapro2.blogspot.com/
I work on Menu 1, but I don't know what to add to make the drop menus to move on right.
<link href='http://fonts.googleapis.com/css?family=Oswald:300,400' rel='stylesheet' type='text/css' />
<link href='http://fonts.googleapis.com/css?family=Yanone+Kaffeesatz:300' rel='stylesheet' type='text/css' />
<div class="nav">
<ul class="menu" id="menu">
<li> home </li>
<li class=""> <a class="drop-ctg" href="#">category</a>
<ul style="overflow: hidden; display: block; height: 0px; z-index: 1072; opacity: 0;">
<li> Category 1 </li>
<li> Category 2 </li>
<li> Category 3 </li>
<li> Category 4 </li>
</ul>
</li>
<li class="">
Menu 1
<ul style="overflow: hidden; display: block; height: 0px; z-index: 1069; opacity: 0;">
<li class="dir">
Menu 2
<ul style="overflow: hidden; display: block; height: 0px; z-index: 1070; opacity: 0;">
<li style="margin-left:50px;"> Menu 3 </li>
<li> Menu 3 </li>
<li> Menu 3 </li>
</ul>
</li>
<li class=" "> Menu 2 </li>
<li> Menu 2 </li>
<li> Menu 2 </li>
</ul>
</li>
<li> Menu 2 </li>
<li> Menu 3 </li>
<li> Menu 4 </li>
<li> 404 Error Page </li>
</ul>
</div>
Here JS fiddle: https://jsfiddle.net/0ugodkb3/2
I want to make Menu 1 to have a droppable menu with menu 2 and on first menu 2, I want to show menu 3.
You can use for that css rule transform with translate value like this:
*{
margin:0;
padding:0;
outline:0;
}
.nav {
width:950px;
height:auto;
border-bottom:1px solid #eee;
margin:10px auto 5px;
display:inline-block;
}
.menu {
width:auto;
list-style:none;
font:$pagenavifont;
text-align:center;
margin:0 auto;
}
.menu a {
float:left;
color:#999;
text-decoration:none;
text-transform:uppercase;
width:auto;
line-height:36px;
padding:0 20px;
}
.menu a:hover,li.menuhover a{
color:#111;
}
.menu li {
position:relative;
float:left;
width:auto;
}
.menu li:last-child {
background:none;
}
.menu ul{
display:none;
position:absolute;
top:36px;
left:0;
background:#fbfbfb;
display:none;
list-style:none;
}
.menu ul li{
float:none;
border-top:1px solid #e3e3e3;
border-right:1px solid #e3e3e3;
border-left:1px solid #e3e3e3;
width:auto;
background:none;
}
.menu ul li:last-child {
border-bottom:1px solid #e3e3e3
}
.menu ul li a{
float:none;
display:block;
background:none;
line-height:36px;
min-width:137px;
width:auto;
text-align:left;
padding-left:10px;
color:#444;
}
.menu ul li a:hover{
background:#fdfdfd;
color:#777;
}
.menu > li > ul {
display: none;
}
.menu > li > ul > li > ul {
transform: translate(100%,0);
display: none;
margin-top: -37px;
}
.menu > li:hover > ul,
.menu > li > ul > li:hover > ul {
display: block;
}
<div class="nav">
<ul class="menu">
<li>
home
</li>
<li class="">
<a class="drop-ctg" href="#">category</a>
<ul>
<li>
Category 1
</li>
<li>
Category 2
</li>
<li>
Category 3
</li>
<li>
Category 4
</li>
</ul>
</li>
<li>
Menu 1
<ul>
<li class="dir">
Menu 2
<ul>
<li>
Menu 3
</li>
<li>
Menu 3
</li>
<li>
Menu 3
</li>
</ul>
</li>
<li>
Menu 2
</li>
<li>
Menu 2
</li>
<li>
Menu 2
</li>
</ul>
</li>
<li>
Menu 2
</li>
<li>
Menu 3
</li>
<li>
Menu 4
</li>
<li>
404 Error Page
</li>
</ul>
</div>
The main thing is to use > selector when defining the display rule for nested menus. This is all what I've added to your css code:
.menu > li > ul {
display: none;
}
/* Position for the 3rd level menu */
.menu > li > ul > li > ul {
transform: translate(100%,0);
display: none;
margin-top: -37px;
}
.menu > li:hover > ul,
.menu > li > ul > li:hover > ul {
display: block;
}
There are a few things that go into making a dropdown menu. It sounds like you're trying to make a dropdown menu that opens up nested menus.
Each pop-out menu will need to:
1) Know the position of the parent that is opening the menu to know where it should be appended.
2) Calculate where the nav should pop up based on where there user is on the browser/screen
You need to append the nav on the right of the menu header you want to open. I'm not sure what your restrictions are but there are vanilla js options:
https://gomakethings.com/how-to-insert-an-element-after-another-one-in-the-dom-with-vanilla-javascript/
that you can use, and also use a mix of position: relative; and position: fixed; to add your nested menus to the right of it's parent.
I would strongly urge you to consider if creating a custom, nested dropdown menu is the right option for you. There are many options out there that have been battle-tested through time. Normally these will also let you style the menu header, and also it's children.
Let me know if you have any more questions :)
Hi I have a basic menu for which I would like to add a submenu, that appears only when a certain menu link is hovered. Everything I have tried does not hide the submenu when a link is not hovered. Here is my code:
CSS
.navmenu{
float:right;
font-size: 13px;
font-weight:400;
text-transform: uppercase;
}
.navmenu li{
position: relative;
display: inline-block;
float: left;
}
.navmenu li a{
text-decoration:none;
color:#eee;
padding:15px 37px 19px 37px;
}
.navmenu li a:hover{
background:#36332e;
}
.active a{
background:#36332e;
}
HTML
<ul class="navmenu">
<li class="active">Home</li>
<li>About Us
<ul>
<li>Sub Link 1</li>
<li>SubLink 2</li>
</ul>
</li>
<li>Testimonials</li>
<li>Services</li>
<li>Contact Us</li>
</ul>
You need to initially hide the menu:
.navmenu li ul { display: none; }
and then display it when you hover over the nav item:
.navmenu li:hover ul { display: none; }
You should also be careful about defining styles that target .navmenu li or .navmenu li a because those will also target your submenu. You should instead use child selectors, giving you more control over the non-submenu links, so your selectors will look like:
.navmenu > li
.navmenu > li > a
I've encorperated some of those changes into this JSFiddle to get you started:
http://jsfiddle.net/Wexcode/B5P26/
Edit:
This is actually going to lose it's hover state when you hover over the submenu links:
.navmenu > li > a:hover {
background:#36332e;
}
Instead, you should do this:
.navmenu ul { position: absolute; }
.navmenu > li:hover { background: #e6332e; }
.navmenu > li > a { display: block; }
Since the <ul> is nested inside the <li> element, you won't lose the hover state when you hover over the submenu links. I updated the fiddle to reflect these changes.
<ul class="navmenu">
<li class="active">Home</li>
<li>About Us
<ul>
<li>
Sub Link 1
<ul>
</li> <a href=# >hi hi hi</a>
<ul>
<li>hello hello hello</li>
<li>hello hello hello</li>
<li>hello hello hello</li>
</ul>
</li>
</li><a href=# >hi hi hi</a> </li>
</li> <a href=# >hi hi hi</a> </li>
</ul>
</li>
<li>SubLink 2</li>
</ul>
</li>
<li>Testimonials</li>
<li>Services</li>
<li>Contact Us</li>
</ul>
I created a code for a drop down menu but when ever I hover over the drop down menu it will open all and not just the one hovered.
Heres my html:
<div class='menuTitle'>
Medical
<div class='menuContent'>
Test<br />
Test2<br />
Test<br />
</div>
</div>
<div class='menuTitle'>|</div>
<div class='menuTitle'>
Bro
<div class="menuContent">
test<br />
comone<br />
</div>
</div>
and my CSS:
.menuTitle {
display: inline-block;
}
.menuContent {
position: absolute;
width: 100px;
background-color: gray;
display: none;
text-align:center;
}
Are your links test, test2 and test? If so you have to put them in seperate divs, better still use ul and li for navigation. You can also use a generator for this http://cssmenumaker.com/
Try:
<div class="dropDown">
<ul>
<li>Test</li>
<li>Test-Dropdown
<ul>
<li>Drop down content</li>
<li>Drop down content</li>
<li>Drop down content</li>
</ul>
</li>
<li>Test</li>
</ul>
</div>
CSS: To active the dropdown do something like this.
.dropDown > ul > li:hover > ul {
display: block;
}
.dropDown > ul > li > ul {
display: none;
position: relative;
bottom: 0;
left: 0;
}
add anymore styles you would like it to have
My fiddle to help you get started
Here is a drop down menu, no javascript needed.
css
menu, menu ul.drop-menu {
padding:0;
margin: 0;}
menu li, menu ul.drop-menu li {
list-style-type: none;
display: inline-block;}
menu li a, menu li ul.drop-menu li a {
text-decoration: none;
color: #fff;
background-color:#000 ;
padding: 5px;
display:inline-block;}
menu li {
position: relative;}
/*drop menu*/
menu li ul.drop-menu {
display:none;
position: absolute;
top: 30px;
left: 0;
width: 100px;}
menu li:hover ul.drop-menu {
display:block;}
html
<ul id="menu">
<li>
Menu 1
<ul class="drop-menu">
<li>
Drop Menu 1
</li>
<li>
Drop Menu 2
</li>
<li>
Drop Menu 3
</li>
<li>
Drop Menu 4
</li>
</ul>
</li>
</li>
<li>Menu 2
<ul class="drop-menu">
<li>
Drop Menu 1
</li>
<li>
Drop Menu 2
</li>
<li>
Drop Menu 3
</li>
<li>
Drop Menu 4
</li>
</ul>
</li>
<li>
Menu 3
</li>
</ul>
I am trying to make a navigation bar with a four columns submenus. I coded most of things, but when I creating the submenu I found the problem.
This is my HTML:
<div id="navigation">
<ul>
<li class="current">
Home
</li>
<li class="sub-menu">
Our Products
<div class="subnav product">
<div class="content">
<div class="col">
<ul>
<li class="one">
Main Menu Item
</li>
<li class="one">
Main Menu Item
</li>
<li class="one">
Main Menu Item
</li>
</ul>
</div>
<div class="col">
<ul>
<li class="two">
<img src="" />
Promoting Peace in the Niger Delta
</li>
<li class="three">
<img src="" />
Promoting Peace in the Niger Delta
</li>
<li class="four">
<img src="" />
Promoting Peace in the Niger Delta
</li>
<li class="five">
<img src="" />
Promoting Peace in the Niger Delta
</li>
</ul>
</div>
</div>
</div>
</li>
<li class="">
Service Maintenance
</li>
<li class="sub-menu">
Frequently Ask Questions
<li class="sub-menu">
Our Products
<div class="subnav product">
<div class="content">
<div class="col">
<ul>
<li class="one">
Main Sub Item
</li>
<li class="one">
Main Sub Item
</li>
<li class="one">
Main Sub Item
</li>
</ul>
</div>
</div>
</div>
</li>
</ul>
</div>
Hope somebody will help me out.
Thank you.
The problem is the container width is defined at 300px
#navigation ul li > div.product {
width: 300px;
}
And its child elements are taking up 100% of that space. So you need to make sure they have room to float left.
#navigation div.col {
float: left;
height:200px;
width: 25%;
}
Hopefully that helps with your question.
Fiddle
Check this http://jsfiddle.net/qtvVK/11/embedded/result/.
I made some changes to your markup and used display:inline-block; instead of floating elements
Relevant CSS syles
/* Dropdown styles */
#navigation ul > li > ul.sub-menu {
display: none;
position:absolute;
padding:10px 0;
background:#fff;
border: 1px solid #DDDCDC;
top: 24px;
z-index: 1;
}
/* Show dropdown when hover */
#navigation ul > li:hover > ul.sub-menu {
display:block;
}
.row {
width:auto;
white-space: nowrap;
}
.col {
display: inline-block;
vertical-align: top;
padding: 0 10px;
}
i suggest using jQuery.
it has simple function called slideDown().
Here is a link to a good tutorial.
You should do like so: First hide your menu when script starts:
$("#idOfDropDownMenu").hide();
And command to drop menu down when mouse enters button and slide up when it leaves it:
$("#idOfButton").hover(function(){ //function that fires when mouse enters
$("#idOfDropDownMenu").slideDown();
}, function() { //function that fires when mouse leaves
$("#idOfDropDownMenu").slideUp();
}
Instead of using IDs you can use any CSS selector.
I hope this helps with your question.
css
ul li ul
{
display: none;
position: fixed;
margin-left: 191px;
margin-top: -37px;
}
ul li:hover ul
{
display: block;
}
ul li a:hover
{
color: #fff;
background: #939393;
border-radius:20px;
}
ul li a
{
display: block;
padding: 10px 10px;
color: #333;
background: #f2f2f2;
text-decoration: none;
}
ul
{
background: #f2f2f2;
list-style:none;
padding-left: 1px;
width: 194px;
text-align: center;
}
html
<ul>
<li>Home</li>
<li>
About
<ul>
<li>About Me
<li>About Site
</ul>
</li>
<li>Contact</li>
</ul>