The sub menu doesn't show up when i hover over the tabs and I have been trying to find a fix for a few days. I have been going over the syntax for a while and I feel like I need a new pair of eyes. Please help as soon as possible.
<header id="header" class="HeaderStyle" style="padding-bottom: 0px; padding-top: 0px;">
<p style="font-size: xx-large; width: 400px;margin-top: 0px;margin-bottom: 0px;margin-right: 0%;"> Sherwood Lego League</p>
<form method="get" action="http://www.google.com/search" style="text-align:right; width: 99%;">
<input type="text" name="q" size="25" maxlength="255" value="" placeholder="Search">
<input type="submit" value="Search">
<input type="hidden" name="sitesearch" value="www.SherwoodLegoLeague.com">
</form>
<navigation id="NavigationLink" class="navigationStyle">
<section class="menu">
<ul>
<li><a class="left_nosub" href="home.html">Home</a></li>
<li><a class="center_hassub" href="teams/teams.html">Teams</a>
<ul>
<li>Team 1</li>
<li>Team 2</li>
<li>Team 3</li>
<li>Team 4</li>
<li>Team 5</li>
</ul>
</li>
<li><a class="center_hassub" href="news/news.html">News</a>
<ul>
<li>Articles</li>
<li>Timeline</li>
</ul>
</li>
<li><a class="right_nosub" href="contactUs.html">Contact Us</a></li>
</ul>
</section>
</navigation>
</header>
CSS section
.menu {
font-family: "TimesNewRoman", Times, serif;
position: relative;
font-size: 11px;
margin: 0;
z-index: 1000;
}
.menu ul li a {
display: block;
text-decoration: none;
color: #f0f0f0;
font-weight: bold;
width: 81px;
height: 42px;
text-align: center;
border-bottom: 0;
background-image: url('../images/MenuPieces/center.png');
line-height: 48px;
font-size: 11px;
overflow: hidden;
padding-left: 1px;
}
.menu .left_nosub {
background-image: url('../images/MenuPieces/left.png');
padding-left: 1px;
margin-right: -1px;
}
.menu .right_nosub {
background-image: url('../images/MenuPieces/right.png');
}
.menu ul {
padding: 0;
margin: 0;
list-style: none;
}
.menu ul li {
float: left;
position: relative;
}
.menu ul li ul {
display: none;
}
.menu ul li:hover a {
color: #000;
background: url('../images/MenuPieces/center_hassub.png');
}
.menu ul li:hover ul li a.center_hassub {
background: #6a3;
color: #000;
}
.menu ul li:hover ul li:hover a.center_hassub {
background: #6fc;
color: #000;
}
.menu ul li:hover ul li ul {
display: none;
}
.menu ul li:hover .left_nosub {
color: #000;
background: url('../images/MenuPieces/left_nosub.png');
}
.menu ul li:hover .right_hassub {
color: #000;
background: url('../images/MenuPieces/right_hassub.png');
}
.menu ul li:hover .right_nosub {
color: #000;
background: url('../images/MenuPieces/right_nosub.png');
}
.menu ul li:hover ul li a {
background-image: none;
display: block;
height: 28px;
line-height: 26px;
color: #000;
width: 142px;
text-align: left;
margin: 0;
padding: 0 0 0 11px;
font-weight: normal;
}
.menu ul li:hover ul {
margin: 0 0 0 3px;
padding: 0;
background-image: url('../images/MenuPieces/dropdown.png');
background-repeat: no-repeat;
background-position: bottom left;
}
.menu ul li:hover ul li a:hover {
color: #000 !important;
background-image: url('../images/MenuPieces/sub_hover.png');
}
.menu ul li:hover ul li:hover ul {
display: block;
position: absolute;
left: 105px;
top: 0;
}
.menu ul li:hover ul li:hover ul.left {
left: -105px;
}
.menu ul li:hover ul .sub_active {
background-image: url('../images/MenuPieces/sub_active.png');
margin-right: 1px;
}
You hid them by default but you forgot to add a display property to them upon hover. You need to add something like display: block; or display: inline-block; or similar property to the .menu ul li:hover ul li a:hover and .menu ul li:hover ul selectors.
JSFiddle
ul li:hover ul {
display:block;
}
Have something like this, so that when you hover over ul li, you display ul.
Related
I've basically copy/pasted the code from Drop-down menu that opens up/upward with pure css
body {
padding: 3em;
}
#menu>li:hover ul {
display: block;
}
#menu * {
padding: 0;
margin: 0;
font: 12px georgia;
list-style-type: none;
}
#menu {
float: center;
text-align: center;
line-height: 10px;
}
#menu a {
display: block;
text-decoration: none;
color: #3B5330;
}
#menu a:hover {
background: #B0BD97;
}
#menu ul {}
#menu ul li ul li a:hover {
background: #ECF1E7;
padding-left: 9px;
border-left: solid 1px #000;
}
#menu ul li ul li {
width: 140px;
border: none;
color: #B0BD97;
padding-top: 3px;
padding-bottom: 3px;
padding-left: 3px;
padding-right: 3px;
background: #B0BD97;
z-index: 1;
}
#menu ul li ul li a {
font: 11px arial;
font-weight: normal;
font-variant: small-caps;
padding-top: 3px;
padding-bottom: 3px;
}
#menu ul li {
float: left;
width: 146px;
font-weight: bold;
border-top: solid 1px #283923;
border-bottom: solid 1px #283923;
background: #979E71;
}
#menu ul li a {
font-weight: bold;
padding: 15px 10px;
}
#menu li {
position: relative;
float: left;
}
#menu ul li ul,
#menu:hover ul li ul,
#menu:hover ul li:hover ul li ul {
display: none;
list-style-type: none;
width: 140px;
bottom: 0;
}
#menu:hover ul,
#menu:hover ul li:hover ul,
#menu:hover ul li:hover ul li:hover ul {
display: block;
}
#menu:hover ul li:hover ul li:hover ul {
position: absolute;
margin-left: 145px;
margin-top: -22px;
font: 10px;
}
#menu:hover ul li:hover ul {
position: absolute;
margin-top: 1px;
font: 10px;
}
#menu>ul>li:hover>ul {
bottom: 100%;
border-bottom: 1px solid transparent
}
<iframe style="width:100%">padding</iframe>
<div id="menu" style="text-align:center; float: center; width: 100%">
<ul>
<li>
<center>item1</center>
<ul>
<li>A</li>
<li>B</li>
<li>C</li>
</ul>
</li>
</ul>
</div>
No matter what I do, I cannot align the menu to sit in the center of the web page.
Your help would be highly appreciated.
Thanks in advance.
Like this? I added the following css:
#menu {
position: absolute;
left: 50%;
transform:translate(-50%, 0);
}
body {
padding: 3em;
}
#menu {
position: absolute;
left: 50%;
transform:translate(-50%, 0);
}
#menu>li:hover ul {
display: block;
}
#menu * {
padding: 0;
margin: 0;
font: 12px georgia;
list-style-type: none;
}
#menu a {
display: block;
text-decoration: none;
color: #3B5330;
}
#menu a:hover {
background: #B0BD97;
}
#menu ul {}
#menu ul li ul li a:hover {
background: #ECF1E7;
padding-left: 9px;
border-left: solid 1px #000;
}
#menu ul li ul li {
width: 140px;
border: none;
color: #B0BD97;
padding-top: 3px;
padding-bottom: 3px;
padding-left: 3px;
padding-right: 3px;
background: #B0BD97;
z-index: 1;
}
#menu ul li ul li a {
font: 11px arial;
font-weight: normal;
font-variant: small-caps;
padding-top: 3px;
padding-bottom: 3px;
}
#menu ul li {
float: left;
width: 146px;
font-weight: bold;
border-top: solid 1px #283923;
border-bottom: solid 1px #283923;
background: #979E71;
}
#menu ul li a {
font-weight: bold;
padding: 15px 10px;
}
#menu li {
position: relative;
float: left;
}
#menu ul li ul,
#menu:hover ul li ul,
#menu:hover ul li:hover ul li ul {
display: none;
list-style-type: none;
width: 140px;
bottom: 0;
}
#menu:hover ul,
#menu:hover ul li:hover ul,
#menu:hover ul li:hover ul li:hover ul {
display: block;
}
#menu:hover ul li:hover ul li:hover ul {
position: absolute;
margin-left: 145px;
margin-top: -22px;
font: 10px;
}
#menu:hover ul li:hover ul {
position: absolute;
margin-top: 1px;
font: 10px;
}
#menu>ul>li:hover>ul {
bottom: 100%;
border-bottom: 1px solid transparent
}
<iframe style="width:100%">padding</iframe>
<div id="menu">
<ul>
<li>
<center>item1</center>
<ul>
<li>A</li>
<li>B</li>
<li>C</li>
</ul>
</li>
</ul>
</div>
You can horizontally center #menu by following CSS rules:
define #menu's display as inline-block
Add a container div outside of #menu and make its text-align as center.
I've made a fiddle for your code, please check.
Update your HTML code as below.
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
<link rel = "stylesheet" type = "text/css" href = "menu.css"/>
<title>Frames Test</title>
</head>
<body>
<iframe style="width:100%">padding</iframe>
<div class="container" style="text-align:center">
<div id="menu" style="text-align:center; float: center;display:inline-block">
<ul>
<li><center>item1</center>
<ul>
<li>A</li>
<li>B</li>
<li>C</li>
</ul>
</li>
</ul>
</div>
</div>
</body>
</html>
This is my nav bar with a drop down menu below some. Book goes below Departments, I have a lot more but this is an example. When I hover over more options, it loses focus on the nav bar and shows the on hover discription for an image. how do i stop this?
<div class="NavBar">
<div align="center">
<ul>
<li>Home</li>
<li>Departments
<ul class="MiniNavBar">
<li>Books</li>
<li>Books</li>
<li>Books</li>
<li>Books</li>
</ul></li>
<li>Top Brands</li>
<li>Gallery</li>
<li>About Us</li>
</ul>
</div>
</div>
My CSS
.NavBar{
background-color: #C10000;
height: auto;
width: 430px;
border: thin solid #000000;
border-radius: 5px;
margin-top: 8px;
}
.MiniNavBar{
width: 97px;
}
.NavBar ul ul {
display: none;
}
.NavBar ul li:hover > ul {
display: block;
font-family: Calibri;
font-size: 10px;
}
.NavBar ul {
padding: 2px;
list-style: none;
position: relative;
display: inline-block;
font-family: Calibri;
font-size: 15px;
}
.NavBar ul li {
float: left;
}
.NavBar ul li:hover {
background-color: #C10000;
color: #FFDD00;
}
.NavBar ul li:hover a {
background-color: #000000;
color: #FFDD00;
}
.NavBar ul li a {
display: block;
padding: 10px 10px;
background-color: #C10000;
color: #FFDD00;
text-decoration: none;
}
.NavBar ul ul {
position: absolute;
}
.NavBar ul ul li {
float: none;
margin-top: 0px;
position: relative;
}
.NavBar ul ul li a {
padding: 15px 40px;
background-color: #C10000;
color: #FFFFFF;
}
.NavBar ul ul li a:hover {
background-color: #C10000;
color: #FFFFFF;
}
.NavBar ul ul ul {
position: absolute;
left: 100%;
top:0;
}
The following code generates a menu to the right of the page, I need that menu to be in a specific position from the bottom-right side of the page.
<html>
<head>
<title>Dropdown menu</title>
<style type="text/css">
body {
padding: 3em;
}
#menu * {
font: 10px;
list-style-type: none;
margin: 0;
padding: 0;
}
#menu {
float: right;
line-height: 5px;
margin-top: 585px;
}
#menu a {
color: #ffffff;
display: block;
text-decoration: none;
}
#menu a:hover {
background: #7A7A7A;
}
#menu ul li ul li a:hover {
background: #AAA7A7;
border-left: solid 1px #000;
padding-left: 9px;
}
#menu ul li ul li {
background: #7A7A7A;
border: none;
padding-bottom: 3px;
padding-left: 3px;
padding-right: 3px;
padding-top: 3px;
width: 120px;
}
#menu ul li ul li a {
font: 11px arial;
font-variant: small-caps;
font-weight: normal;
padding-bottom: 3px;
padding-top: 3px;
position: relative;
}
#menu ul li {
background: #383838;
font: 14px arial;
font-weight: bold;
width: 126px;
}
#menu ul li a {
font-weight: bold;
padding: 15px 10px;
}
#menu li {
float: left;
position: relative;
}
#menu ul li ul, #menu:hover ul li ul, #menu:hover ul li:hover ul li ul {
display: none;
list-style-type: none;
width: 120px;
}
#menu:hover ul, #menu:hover ul li:hover ul, #menu:hover ul li:hover ul li:hover ul {
display: block;
}
#menu:hover ul li:hover ul li:hover ul {
border-bottom: transparent;
font: 10px;
margin-left: 145px;
margin-top: -22px;
position: absolute;
}
#menu:hover ul li:hover ul {
border-bottom: transparent;
bottom: 100%;
font: 10px;
margin-top: 1px;
position: absolute;
}
</style>
</head>
<body>
<div id="menu">
<ul>
<li>
<center>ARCHITECTURE</center>
<ul>
<li>RESIDENTIAL</li>
<li>COMMERCIAL</li>
</ul>
</li>
<li>
<center>INTERIORS</center>
</li>
<li>
<center>FURNITURE</center>
<ul>
<li>SEATING</li>
<li>TABLES</li>
<li>CABINETS</li>
</ul>
</li>
<li>
<center>ABOUT</center>
</li>
<li>
<center>CONTACT</center>
</li>
</ul>
</div>
</body>
</html>
You can view it in action here: JSFiddle
In order to specify the position from the bottom right corner, you should use an absolute positioning :
#menu {
position: absolute;
bottom: 10px;
right: 10px;
}
Demo
Below is my code, currently when I hover on "About Us" everything below the dropdown menu opens; how can i change the css so that it only hovers when i mouseover, this means, when i hover on "Team", then I should see the menus below it.
also how can i adjust the width so that it is shiffted more to the left.
also when the dropdown menu is longer in lenth, it hides below my content, i want the dropdown menu to be over the body of the page, not in hiding.
thanks in advance you all.
<style>
ul {
font-family: Arial, Verdana;
font-size: 14px;
margin: 0;
padding: 0;
list-style: none;
}
ul li {
display: block;
position: relative;
float: left;
}
li ul { display: none; }
ul li a {
display: block;
text-decoration: none;
color: #ffffff;
border-top: 1px solid #ffffff;
padding: 5px 15px 5px 15px;
background: #000061;
margin-left: 1px;
white-space: nowrap;
}
ul li a:hover { background: #617F8A; }
li:hover ul {
display: block;
position: absolute;
}
ul li:hover li {
float: none;
font-size: 11px;
}
li:hover a { background: #617F8A; }
li:hover li a:hover { background: #95A9B1; }
</style>
<body>
<ul id="menu">
<li><b>Home</b></li>
<li><b>About Us</b>
<ul>
<li>Team
<ul>
<li>Profile</li>
<li>Board</li>
</ul>
</li>
</ul>
</li>
<ul>
</body>
JSFiddle: http://jsfiddle.net/LWEry/
Like this:
ul {
font-family: Arial, Verdana;
font-size: 14px;
margin: 0;
padding: 0;
list-style: none;
}
ul li {
display: block;
position: relative;
float: left;
}
li ul { display: none; }
ul li a {
display: block;
text-decoration: none;
color: #ffffff;
border-top: 1px solid #ffffff;
padding: 5px 15px 5px 15px;
background: #000061;
margin-left: 1px;
white-space: nowrap;
}
ul li a:hover { background: #617F8A; }
li:hover > ul {
display: block;
position: absolute;
width: 100%;
}
ul li:hover li {
float: none;
font-size: 11px;
}
li:hover a { background: #617F8A; }
li:hover li a:hover { background: #95A9B1; }
.sub-menu
{
position: absolute;
top: 0;
left: 100%;
}
http://jsfiddle.net/3xWcu/2/
I changed one selector.
FROM
li:hover ul
TO
li:hover > ul
Edited my fiddle above. Added a sub-menu class to the ul containing the Profile and Board li tags:
<ul class="sub-menu">
<li>Profile</li>
<li>Board</li>
</ul>
and added some CSS above.
You mean like this? http://jsfiddle.net/3xWcu/
<style>
ul {
font-family: Arial, Verdana;
font-size: 14px;
margin: 0;
padding: 0;
list-style: none;
}
ul li {
display: block;
position: relative;
float: left;
}
li ul { display: none; }
ul li a {
display: block;
text-decoration: none;
color: #ffffff;
border-top: 1px solid #ffffff;
padding: 5px 15px 5px 15px;
background: #000061;
margin-left: 1px;
white-space: nowrap;
}
ul li a:hover { background: #617F8A; }
li:hover ul {
display: block;
position: absolute;
width: 100%;
}
ul li:hover li {
float: none;
font-size: 11px;
}
li:hover a { background: #617F8A; }
li:hover li a:hover { background: #95A9B1; }
</style>
<body>
<ul id="menu">
<li><b>Home</b></li>
<li><b>About Us</b>
<ul>
<li>Team
<ul>
<li>Profile</li>
<li>Board</li>
</ul>
</li>
</ul>
</li>
<ul>
</body>
I have a drop down menu I'm building for my HTML5 site and I've got the coding correct (or so I think) and the drop down is not appearing just the top level elements.
I have scanned through the Code and as far as I'm aware, the code seems ok. I place the code below and see if you can spot the error:
<navigation id="NavigationLink" style="" class="navigationStyle">
<section class="menu">
<ul>
<li><a class="left_nosub" href="default.html">Home</a></li>
<li><a class="center_hassub" href="products.html">Products</a>
<ul>
<li>Graphic Design</li>
<li>Web Design</li>
<li>Content Management Systems</li>
<li>Social Media Design</li>
</ul>
</li>
<li><a class="center_hassub" href="#">News</a>
<ul>
<li>Current Projects</li>
<li>Day-To-Day-Stuff</li>
</ul>
</li>
<li><a class="right_nosub" href="#">Contact Us</a></li>
</ul>
</section>
.menu {
font-family: Arial, Helvetica, sans-serif;
position: relative;
font-size: 11px;
margin: 0;
z-index: 1000;
}
.menu ul li a {
display: block;
text-decoration: none;
color: #f0f0f0;
font-weight: bold;
width: 80px;
height: 42px;
text-align: center;
border-bottom: 0;
background-image: url(images/center.png);
line-height: 48px;
font-size: 11px;
overflow: hidden;
padding-left: 1px;
}
.menu .left_nosub {
background-image: url(images/left.png);
padding-left: 1px;
margin-right: -1px;}
.menu .right_nosub {
background-image: url(images/right.png);
}
.menu ul {
padding: 0;
margin: 0;
list-style: none;
}
.menu ul li {
float: left;
position: relative;
}
.menu ul li ul {
display: none;
}
.menu ul li:hover a {
color: #000;
background: url(images/center_hassub.png);
}
.menu ul li:hover ul li a.center_hassub {
background: #6a3;
color: #000;
}
.menu ul li:hover ul li:hover a.center_hassub {
background: #6fc;
color: #000;
}
.menu ul li:hover ul li ul {
display: none;
}
.menu ul li:hover .left_nosub {
color: #000;
background: url(images/left_nosub.png);
}
.menu ul li:hover .right_hassub {
color:#000;
background: url(images/right_hassub.png);
}
.menu ul li:hover .right_nosub {
color: #000;
background: url(images/right_nosub.png);
}
.menu ul li:hover ul li a {
background-image: none;
display: block;
height: 28px;
line-height: 26px;
color: #000;
width: 142px;
text-align: left;
margin: 0;
padding: 0 0 0 11px;
font-weight: normal;
}
.menu ul li:hover ul{
margin: 0 0 0 3px;
padding: 0;
background-image: url(images/dropdown.png);
background-repeat: no-repeat;
background-position: bottom left;
}
.menu ul li:hover ul li a:hover {
color: #000 !important;
background-image: url(images/sub_hover.png);
}
.menu ul li:hover ul li:hover ul {
display: block;
position: absolute;
left: 105px;
top: 0;
}
.menu ul li:hover ul li:hover ul.left {
left: -105px;
}
.menu ul li:hover ul .sub_active {
background-image: url(images/sub_active.png);
margin-right: 1px;
}
Change the following class
.menu ul li:hover ul{
margin: 0 0 0 3px;
padding: 0;
background-image: url(images/dropdown.png);
background-repeat: no-repeat;
background-position: bottom left;
display:block;
}