SEE LIVE MENU HERE.
I am trying to figure out why the drop-down disappears after you attempt to rollover it. Can someone see the problem in my code? Thank you.
HERE IS MY HTML MENU
<div id="menu">
<ul>
<li><span>Needs Assessment</span> </li>
<li><span>Knowledge Acquisition</span>
<ul>
<li>Administer Knowledge<br>Pre-Test</li>
<li>Assign Asthma<br>Article </li>
<li>Administer Knowledge<br>Post-Test</li>
<li>Discuss Asthma<br>Case Study</li>
</ul>
</li>
<li><span>Skills Proficiency</span> </li>
<li><span>Simulation in Teams</span>
<ul>
<li>Perform Asthma<br>Simulation</li>
<li>Facilitate<br>Debriefing</li>
</ul>
</li>
<li><span>Performance</span></li>
<li><span>Resources</span></li>
</ul>
</div>
HERE IS MY CSS
#menu {
position: relative;
top: 10px;
left: 0px;
width: 940px;
height: 47px;
}
#menu ul {
position: relative;
top: -15px;
left: 0px;
margin-left: 0px;
padding-left: 0px;
list-style: none;
}
#menu ul li {
position: relative;
display: inline;
float: left;
list-style: none;
margin-right: 0px;
border: solid 0px #4981a8;
width: 156px;
background-image: url ('http://www.laerdal.com/Laerdal/usa/discoversimulation/images/button.png');
background-repeat: no-repeat;
}
#menu ul li a {
display: block;
width: 156px;
padding: 12px 0px 10px 0px;
border: solid 0px #fff;
font-family: 'Cabin', sans-serif;
font-size: 14px;
font-weight: lighter;
text-align: center;
text-decoration: none;
}
#menu a span {
float: left;
display: block;
padding: 3px 5px 4px 6px;
color:#fff;
float: none;
}
#menu a:hover span {
color:#ffdd00;
}
#menu li ul {
position: absolute;
top: 47px;
left: 0px;
background-color:#4981a8;
border: solid 1px #4981a8;
display: none;
}
#menu li:hover ul {
display: block;
z-index: 999;
}
#menu li li a {
font-family: 'Cabin', sans-serif;
font-size: 14px;
color: #000;
font-weight: lighter;
height: 38px;
background-color:#eee;
margin-bottom: -9px;
}
#menu li li a:hover {
color: #065389;
}
You have another element on your page that's partially covering up the navigation:
#textbox {
position: relative;
top: -30px;
}
This is blocking the :hover. To solve this, give your #header a z-index:1. Any positive value should work, you just need to set it to something so the element stays on top.
Related
.menu li {
float: left;
color: #fff;
font-weight: bold;
}
.menu li a {
display: block;
height: 20px;
min-width: 110px;
text-decoration: none;
border-radius: 3px;
padding: 4px;
padding-left: 6px;
padding-right: 6px;
margin-left: 25px;
margin-right: 25px;
}
.menu li ul {
display: none;
max-width: 110px;
padding: 4px;
margin-left: 25px;
margin-right: 25px;
list-style: none !important;
list-style-image: none !important;
}
.menu li a:hover {
background-color: rgba(0, 88, 153, 0.8);
}
.menu li:hover ul {
display: block;
padding: 0;
margin-top: 9px;
list-style: none !important;
list-style-image: none !important;
}
.menu li:hover ul a {
display: block;
background-color: rgba(0, 88, 153, 0.8);
width: 110px;
border-radius: 3px;
padding-top: 6px;
padding: 4px;
padding-left: 6px;
padding-right: 6px;
text-align: left;
margin: 0;
margin-bottom: 5px;
Above here the code I'm currently using, I want the UL to float above everything, I tried 'fixed' and 'absolute' but then it disappears, I tried to change 'margin-left' to 'inherit' but that didn't work either. I want the UL to float beneath the parent LI.
JSFiddle
You need to position the submenu absolutely after first having positioned the parent li relative
HTML (Corrected) (with thanks to #Malcom for the container
<div class="container">
<div class="menu">
<ul>
<li>Home
</li>
<li>Sub
<ul>
<li>Sub1
</li>
<li>Sub2
</li>
<li>Sub3
</li>
</ul>
</li>
</ul>
</div>
</div>
As you can see, this text moves when you hover 'Sub'
CSS (clipped to relevant parts)
.menu li {
float: left;
color: #fff;
font-weight: bold;
position: relative; /* this */
}
.menu li ul {
position: absolute; /* this */
display: none;
max-width: 110px;
padding: 4px;
margin-left: 25px;
margin-right: 25px;
list-style: none !important;
list-style-image: none !important;
}
JSfiddle Demo
I am trying to create a drop down menu similar to the one found on this website http://yachtbelleaimee.com/
I have created the drop down menu however I do not know how to position the lists like that found in the website. And like the website I would also like to known how to position the list below the header. Thank you very much for any help you can provide
/* NAVIGATION START */
nav {
display: block;
width: 960px;
margin: 100px auto;
text-align: center;
}
nav select {
display: none;
}
#menu {
width: 608px;
margin-top: 0px;
margin-right: auto;
margin-bottom: 0px;
margin-left: auto;
padding-top: 0px;
padding-right: 0px;
padding-bottom: 0px;
padding-left: 0px;
}
#menu ul {
margin: 0px;
padding: 0px;
}
#menu ul li {
background-color: #666;
float: left;
border: 1px solid #CCC;
position: relative;
list-style-type: none;
}
#menu ul li:hover ul {
visibility: visible;
background-color: #333;
}
#menu ul li a {
font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
font-size: 14px;
line-height: 30px;
color: #FFF;
text-decoration: none;
text-align: center;
display: block;
height: 30px;
width: 150px;
}
#menu ul ul {
position: absolute;
visibility: hidden;
left: -1px;
top: 31px;
}
#menu ul li:hover {
background-color: #333;
}
#menu ul li ul li a:hover {
background-color: #069;
}
#menu ul li a:hover {
color: #0FF;
}
#leftmenu {
position: absolute;
left: 165px;
top: 20px;
}
#rightmenu {
position: absolute;
right: 164px;
top: 20px;
}
/* NAVIGATION END */
<nav>
<div id="menu">
<ul id='leftmenu'>
<li>BOAT
<ul>
<li><a href='#'>Specs & Boat Plans</a></li>
<li><a href='#'>Itineraries</a></li>
<li><a href='#'>Exteriors</a></li>
<li><a href='#'>Diving & Water Toys</a></li>
</ul>
</li>
</ul>
<ul id='rightmenu'>
<li>LIFE ON BOARD
<ul>
<li><a href='#'>Itineraries</a></li>
<li><a href='#'>Dining</a></li>
<li><a href='#'>Family Fun</a></li>
<li>Lifelong Learning</li>
<li>The Crew</li>
</ul>
</li>
</ul>
</div>
</nav>
Here's some CSS to get you started:
/* NAVIGATION START */
nav {
display: block;
width: 960px;
margin: 100px auto;
text-align: center;
}
nav select {
display: none;
}
#menu {
width: 608px;
margin-top: 0px;
margin-right: auto;
margin-bottom: 0px;
margin-left: auto;
padding-top: 0px;
padding-right: 0px;
padding-bottom: 0px;
padding-left: 0px;
}
#menu ul {
margin: 0px;
padding: 0px;
}
#menu ul li {
background-color: #666;
float: left;
border: 1px solid #CCC;
position: relative;
list-style-type: none;
}
#menu ul li:hover ul {
visibility: visible;
}
#menu ul li a {
font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
font-size: 14px;
line-height: 30px;
color: #FFF;
text-decoration: none;
text-align: center;
display: block;
height: 30px;
width: 150px;
}
#menu ul ul {
position: absolute;
visibility: hidden;
left: -1px;
top: 31px;
}
#menu ul li:hover {
background-color: #333;
}
#menu ul li ul li a:hover {
background-color: #069;
}
#menu ul li a:hover {
color: #0FF;
}
#leftmenu {
position: absolute;
left: 165px;
top: 20px;
}
#leftmenu li>ul>li {
margin:1em 0;
}
#leftmenu li:nth-child(2) {
margin-left:20px;
}
#leftmenu li:nth-child(3) {
margin-left:40px;
}
#leftmenu li:nth-child(4) {
margin-left:60px;
}
#rightmenu {
position: absolute;
right: 164px;
top: 20px;
}
#rightmenu li>ul>li {
margin:1em 0;
}
#rightmenu li:nth-child(2) {
margin-left:-20px;
}
#rightmenu li:nth-child(3) {
margin-left:-40px;
}
#rightmenu li:nth-child(4) {
margin-left:-60px;
}
#rightmenu li:nth-child(5) {
margin-left:-80px;
}
And a JSFiddle.
You can simplify
#menu {
width: 608px;
margin-top: 0px;
margin-right: auto;
margin-bottom: 0px;
margin-left: auto;
padding-top: 0px;
padding-right: 0px;
padding-bottom: 0px;
padding-left: 0px;
}
to
#menu {
width: 608px;
margin: 0px auto;
padding: 0px;
}
For that... er... cascading effect, you'll probably have to use something like
<li style="padding-left: some value here">
and decrease it with each <li> (since you're floating them right). Also, the menu will have to be as wide as the space that goes from the leftmost menu item to the rightmost; it cannot be as wide as one menu item.
This is my JSFIDDLE DEMO
Hover works fine, but I want to show the sub menu when i click on an option locks the submenu and then if hover on the main menu, display sub menu options but to stay on the other,
any help?
<div id="cssmenu">
<div class="divul">
<ul>
<li class="has-sub">
<a>Buscador</a>
<ul>
<li><a>Busqueda Datos</a></li>
<li><a>Estadisticas</a></li>
</ul>
</li>
<li class="has-sub">
<a>Clientes</a>
<ul>
<li><a>Buscador Clientes</a></li>
<li><a>Nuevo Cliente</a></li>
</ul>
</li>
<li class="has-sub">
<a>Incidencias</a>
<ul>
<li><a>Nuevo Incidencia</a></li>
<li><a>Buscador Incidencias</a></li>
</ul>
</li>
</ul>
</div>
#cssmenu{
border-bottom: 1px solid #278204;
margin-top: 10px;
}
#cssSubmenu{
background-color: #CCCCCC;
height: 30px;
/*margin-top: 10px;*/
}
#cssmenu ul{
height: 21px;
display: inline-block;
background-color: #278204;
margin-left: 15px;
padding-top: 5px;
}
.divul{
background:
url(/CI_Gestion_incidencias/images/menuL.png) left no-repeat,
url(/CI_Gestion_incidencias/images/menuR.png) right no-repeat;
display: inline-block;
padding-right: 29px;
margin-left: -3px;
}
#cssmenu ul li
{
height: 30px;
color: #FFF;
list-style: none;
display: inline;
padding-right: 20px;
padding-left: 10px;
padding-top: 5px;
padding-bottom: 4px;
z-index: 1000;
}
/**
**/
/*#cssmenu li a {
color: #666666;
display: block;
font-weight: bold;
line-height: 30px;
padding: 0px 25px;
text-align: center;
text-decoration: none;
}
*/
#cssmenu li:hover {
background: #CCCCCC;
color: #000;
text-decoration: none;
}
#cssmenu li ul {
background: #CCCCCC;
display: none;
height: 25px;
filter: alpha(opacity=95);
opacity: 0.95;
position: absolute;
z-index: 200;
margin-left: 0px;
margin-top: 2px;
width: 100%;
}
#cssmenu li:hover > ul {
display: block;
}
#cssmenu li li {
display: block;
color: #000;
display: inline;
/* float: none;
padding: 0px;
position: relative;*/
}
#cssmenu li li:active {
display: block;
color: #000;
display: inline;
}
#cssmenu li ul a {
color: #000;
display: inline;
font-size: 12px;
font-weight: bold;
text-align: left;
text-decoration: none;
}
If you want show on click then use jquery.
You can try below code:
Demo
$('.has-sub a').click(function(){
$('.has-sub ul').hide();
$(this).next().show();
});
You can use tabindex="0" in HTMl and :focus in CSS together: DEMO
<li class="has-sub" tabindex="0">
#cssmenu li:hover > ul,
#cssmenu li:focus > ul{
display: block;
}
http://jsfiddle.net/msbyuva/QPQqs/
Hi I have a menu formed using
<ul class="topnav">
<li>#Html.ActionLink("Configuration", "Configuration", "Home")</li>
<li>#Html.ActionLink("Reporting", "Reporting", "Home")
<ul class="subnav">
<li>#Html.ActionLink("Pipeline", "Pipeline", "Pipeline", null, new { target = "_blank", Url = "http://storespipeline/stores/" })</li>
<li>D2C OBI Reports</li>
<li>#Html.ActionLink("Device Utilization", "DeviceUtilization", "DeviceUtilization")</li>
<li>#Html.ActionLink("Display Audit", "DisplayAudit", "DisplayAudit")</li>
<li>#Html.ActionLink("TrueVUE Reports", "TrueVUE", "TrueVUE")</li>
</ul>
</li>
<li>#Html.ActionLink("Admin", "Admin", "Home")</li>
</ul>
CSS:
ul.topnav
{
list-style: none;
padding: 10px;
margin: 0;
float: left;
width: 100%;
background: #f6f6f6;
font-size: 1em;
color: Black;
}
ul.topnav li
{
float: left;
margin: 0;
padding: 0 15px 0 0;
position: relative;
}
ul.topnav li a
{
padding: 5px 0px 0px 0px;
color: black;
display: table;
text-decoration: none;
float: left;
}
ul.topnav li a:hover
{
text-decoration: underline;
font-weight: bold;
}
ul.topnav li span.subhover
{
}
ul.topnav li ul.subnav
{
list-style: none;
position: absolute;
left: 0px;
top: 25px;
background: #f6f6f6;
margin: 0;
padding: 0px 0px 0px 0px;
height: auto;
display: none;
float: left;
min-width: 100px;
width: auto;
}
ul.topnav li ul.subnav li
{
margin: 0px;
padding: 4px 10px 0px 10px;
height: auto;
line-height: 100%;
}
html ul.topnav li ul.subnav li a
{
float: left;
width: 150%;
margin: 0px;
padding: 0px 0px 0px 0px;
text-align: left;
}
html ul.topnav li ul.subnav li a:hover
{
}
</style>
When I click on a link example -- Display Audit -- when the page gets loaded -- the menu link is underneath the page content... that can be seen in the image (the last two links go underneath the page content)..... how can I display the menu link above the page content??
I am using IE7, CSS 2.1
You need to use a z-index. For z-index to work both the navigation container and the content container need to have a position of relative, absolute or fixed. For your example I would suggest a relative positioning.
.topnav {
position:relative;
z-index:1000;
}
.yourContentContainer{
position:relative;
z-index:1;
}
I created a css drop down menu and i am finishing it up with a border. When i added the left and bottom border everything was fine. Once i added the right border it put a gap between the right border and the drop down menu. Is there anyway to fix this?
Here is a photo http://sphotos-b.ak.fbcdn.net/hphotos-ak-ash3/563034_641717089180441_1749213926_n.jpg
The HTML I Used:
<nav id="main_nav" class="fluid">
<ul>
<li>Home</li>
<li>Show Services
<ul>
<li>Audio</li>
<li>Lighting</li>
<li>Power</li>
<li>Special Effects</li>
<li>Staging/Trussing</li>
<li>Video</li>
</ul>
</li>
<li>Systems Integration
<ul>
<li>Corporate and Commercial</li>
<li>Digital Signage</li>
<li>Entertainment</li>
<li>IP Based Systems</li>
</ul>
</li>
<li>Portfolio
<ul>
<li>Concrets</li>
<li>Installations</li>
<li>Parties</li>
<li>Product Launch</li>
<li>Trade Shows</li>
</ul>
</li>
<li>Our Company</li>
</ul>
</nav>
The CSS I Used:
#main_nav {
}
#main_nav ul {
list-style-type: none;
margin-top: 0%;
margin-right: 0%;
margin-bottom: 0%;
margin-left: 0%;
padding-top: 0%;
padding-right: 0%;
padding-bottom: 0%;
padding-left: 0%;
width: 100%;
position: relative;
float: left;
}
#main_nav ul li {
float: left;
position: relative;
width: 20%;
margin-top: 0%;
margin-right: 0%;
margin-bottom: 0%;
margin-left: 0%;
padding-top: 0%;
padding-right: 0%;
padding-bottom: 0%;
padding-left: 0%;
background-color: #4d4d4d;
}
#main_nav ul li a {
width: 100%;
float: left;
text-align: center;
text-transform: uppercase;
color: #FFFFFF;
text-decoration: none;
padding-top: 0%;
font-style: normal;
font-weight: 400;
font-family: allerta;
font-size: 1em;
display: block;
padding-right: 0%;
padding-bottom: 0%;
padding-left: 0%;
margin-top: 0%;
margin-right: 0%;
margin-bottom: 0%;
margin-left: 0%;
border-left: 0.1em solid #999999;
border-bottom: 0.1em solid #999999;
border-right: 0.1em solid #999999;
}
#main_nav a:hover, #main_nav a:active, #main_nav a:focus, #main_nav a.thispage {
background-color: #666666;
color: #0099FF;
width: 100%;
}
#main_nav ul li ul {
visibility: hidden;
margin-right: 0%;
margin-bottom: 0%;
margin-left: 0%;
padding-right: 0%;
padding-bottom: 0%;
padding-left: 0%;
float: left;
list-style-type: none;
position: absolute;
margin-top: 100%;
padding-top: 0%;
width: 100%;
top: 0px;
right: 0px;
bottom: 0px;
left: 0px;
}
#main_nav ul li ul li {
position: relative;
float: left;
width: 100%;
margin-top: 0%;
margin-right: 0%;
margin-bottom: 0%;
margin-left: 0%;
padding-top: 0%;
padding-right: 0%;
padding-bottom: 0%;
padding-left: 0%;
background-color: #4d4d4d;
}
#main_nav ul li ul li a {
width: 100%;
padding-right: 0%;
padding-bottom: 0%;
padding-left: 0%;
margin-top: 0%;
margin-right: 0px;
margin-bottom: 0px;
margin-left: 0px;
padding-top: 0%;
float: left;
font-style: normal;
font-weight: 400;
font-family: allerta;
font-size: 0.9em;
text-align: center;
text-decoration: none;
display: block;
color: #FFFFFF;
text-transform: uppercase;
}
#main_nav ul li:hover ul, #main_nav ul li:active ul, #main_nav ul li:focus ul, #main_nav ul li.thispage ul {
visibility: visible;
width: 100%;
}
I took a look at your code and have made some changes. Also took the liberty of creating a JS Fiddle example for you. I haven't changed any HTML, only the CSS.
See JS Fiddle here
html {
font: 100%/1.5 Arial, Helvetica, sans-serif;
}
html, body {
margin: 0;
}
/* Common (Shared) Properties */
#main_nav, ul, li, a {
display: block;
margin: 0;
padding: 0;
}
#main_nav ul {
list-style: none;
width: 100%;
position: relative;
float: left;
}
#main_nav li {
float: left;
position: relative;
width: 20%;
background: #4d4d4d;
}
#main_nav a {
float: none;
text-align: center;
text-transform: uppercase;
color: #FFF;
text-decoration: none;
font-size: 1em;
border: 1px solid #999;
border-top: none;
}
#main_nav a:hover,
#main_nav a:active,
#main_nav a:focus,
#main_nav a.thispage {
background: #666;
color: #FFF;
}
/* Controls Dropdown */
#main_nav ul li ul {
visibility: hidden;
position: absolute;
top: auto; /* Updated position to 'auto' and removed margin-top: 100% */
left: 0;
}
#main_nav ul ul li {
float: none;
width: 100%;
}
#main_nav ul li:hover ul,
#main_nav ul li:active ul,
#main_nav ul li:focus ul,
#main_nav ul li.thispage ul {
visibility: visible;
display: block;
}
I rewrote CSS which hopefully will be helpful to learn from as it is much simpler to understand as well as it fixes your problem.
Problem was that the sub menu items were with 100% width + 1px border on each side which is over 100% so it was overflowing.
Here is the link to JS Fiddle example with fix: http://jsfiddle.net/MartinTale/69gDQ/3/
Here is the new css:
#main_nav ul {
list-style-type: none;
margin: 0;
padding: 0;
}
#main_nav ul {
width: 100%;
}
#main_nav li {
background-color: #4d4d4d;
margin: 0;
padding: 0;
text-align: center;
width: 100%;
}
#main_nav > ul > li {
float: left;
width: 20%;
}
#main_nav ul ul {
display: none;
}
#main_nav ul li:hover ul {
display: inline-block;
}
#main_nav a {
text-align: center;
text-decoration: none;
color: #FFF;
text-transform: uppercase;
display: inline-block;
width: 100%;
border-left: 1px solid #999999;
border-bottom: 1px solid #999999;
border-right: 1px solid #999999;
}
#main_nav ul li ul a {
border-left: 0;
border-right: 0;
}
#main_nav a:hover,
#main_nav a:active,
#main_nav a:focus,
#main_nav a.thispage {
background: #666;
color: #09F;
}