What am I missing in making a dropdown nav? - html

As stated above, what am I not seeing in my coding (html and CSS) to make a standard list dropdown in my nav?
When I go to preview this portion of the page in Chrome and IE the nav section looks fine until I hover over my Fishing and Guides link. It hides the other selections when it's supposed to display the main sections along with different subsections within a particular subject.
Do I also need to incorporate jquery to make this work?
#topnav {
background-color: #333333;
clear: both;
border-bottom: 3px #cccccc solid;
overflow: hidden;
}
#topnav ul {
width: 100%;
float: left;
margin: 0px;
background-color: #333333;
position: relative;
}
#topnav ul li {
display: inline
}
#topnav ul li a {
float: left;
padding: 10px 20px;
color: white;
text-decoration: none;
}
#topnav a:visited {
color: #ffffff;
}
#topnav a:active {
color: #ffffff;
}
#topnav a:hover {
color: #ffffff;
background-color: maroon;
}
#topnav a:focus {
color: #ffffff;
}
#topnav ul li img {
vertical-align: middle;
padding-left: 8px;
width: 22px;
height: 18px;
}
#topnav ul li:hover ul {
display: block;
}
#topnav ul ul {
display: none;
position: absolute;
background-color: #333333;
border: 5px #333333 solid;
border-top: 0px;
margin-left: -5px;
min-width: 100px;
}
#topnav ul ul li {
display: block
}
#topnav ul ul li a:visited {
color: #ffffff;
}
#topnav ul ul li a:hover {
color: #ffffff;
background-color: maroon;
}
#topnav ul ul li a:focus {
color: #ffffff;
}
<div id="topnav">
<ul>
<li> Home
</li>
<li>
Fishing & Guides<img src="Images/bearpawwhitenav.png"/>
<ul>
<li>Fishing Tips
</li>
</ul>
</li>
<li>
Accommodations
</li>
<li>
Area & History
</li>
<li>
Rates
</li>
<li>
Contact
</li>
</ul>
</div>

When you :hover fishing guides you are showing fishing tips. The fishing tips is hiding the rest of your nav, it's sitting ontop. You should position it so it appears below the main nav. Carl is right, bootstrap is great resource for building these types of things.

Related

keeping parent nav background active when on child page - CSS Weebly

I'm trying to keep the parent nav background active when on child page.
Example: Portfolio---->Programs
When my current page is Programs, I'd like to keep the Portfolio active on the navigation bar.
The code use in the CSS is:
/* Navigation
--------------------------------------------------------------------------------*/
#nav-wrap {
max-height: 200px;
}
#nav .container ul {
list-style: none !important;
}
#nav .container ul li {
list-style: none !important;
}
#nav .container ul span:last-child li,
#nav .container ul > li:last-child {
/*background: none;*/
background:url(surf_40.gif) no-repeat -12px;
}
#nav ul li a {
display: block;
font-size:30px;
line-height: 35px;
padding: 10px 0;
color: rgba(255,255,255,0.4);
padding: 2px 25px 2px 21px;
border: 0;
outline: 0;
list-style-type: none;
position:relative;
right:-4px;
z-index:1;
text-transform: uppercase;
font-family: 'Aller', sans-serif;
}
#nav ul li#active a {
background: url(surf_40.gif) no-repeat -12px;
}
#nav ul li#active a,
#nav ul li a:hover {
color: #fff;
border: 0;
}
/**Text modified added - for active parent while my current page is a sub-menu***/
#wsite-menus .wsite-menu li #active a #nav ul li a {
color: #fff;
border: 0;
}
/*---*/
/* Navigation Submenu's
--------------------------------------------------------------------------------*/
#wsite-menus .wsite-menu li a {
color: rgba(0,0,0,0.4);
font-weight: bold;
background: #fff;
/*border: 0 px;*/
border: solid thick;
border-radius: 1em;
/* fine modifica*/
position:relative;
right: 0 px;
}
#wsite-menus .wsite-menu li a:hover {
color: #000;
background: #e3e3e3;
border: solid thick orange;
}
thank you for any help..
HTML code:
<div id="nav">
<ul class='wsite-menu-default'>
<li id='pg962547086691527768'><a href="/" data-membership-required="0" >Home</a></li>
<li id='pg623326219140352077'><a href="/about.html" data-membership-required="0">About</a</li>
</ul></div>
Put the :hover on li's instead of a:hover and alos add class active to li. if you provide html two then i will provide you the perfect solution thanks

What CSS is causing this submenu to be lower than it should be?

JSFIDDLE
If you hover over products, a dropdown menu should appear (displaying appliance and other), then when you hover over appliance, another submenu should appear (displaying black and white), however this second submenu appears to be 2-3 pixels lower than the parent menu. What CSS is causing it to be lower?
Here's the CSS:
*{
margin: 0px;
padding: 0px;
}
#navbar{
list-style: none;
float: right;
padding-top: 54px;
position: relative;
}
#navbar li{
float:left;
width: 130px;
text-align: center;
}
#navbar li a{
text-decoration: none;
font-family: "Open Sans", sans-serif;
font-size: 12px;
color: #524F4F;
font-weight: 600;
}
#navbar li a:hover{
color: #f3a82e;
}
#navbar ul{
list-style: none;
display: none;
position: absolute;
top: 100%;
}
.firstnavmenu{
padding-top: 10px;
}
#navbar ul li{
float: none;
position: relative;
background-color:#f9f9f9;
height: 30px;
border-top: 3px solid white;
}
#navbar ul li a{
padding-top: 6px;
width: 100%;
height: 100%;
display: block;
}
#navbar li:hover > ul{
display: block;
}
#navbar li li:hover{
background-color: #edeaea;
}
#navbar ul ul{
position: absolute;
left: 100%;
top:0;
display: none;
}
#navbar ul ul:hover > ul {
display: block;
}
and heres the html:
<ul id="navbar">
<li>
PRODUCTS
<ul class="firstnavmenu">
<li>
APPLIANCE
<ul>
<li>BLACK </li>
<li>WHITE</li>
</ul>
</li>
<li>OTHER</li>
</ul>
</li>
<li>
TECHNOLOGY
</li>
<li>
PARTNERS
</li>
<li>
COMPANY
</li>
</ul>
Your 3 px solid white border.
Remove it from the 2nd ul li:first-child
#navbar ul ul li:first-child {
border-top:none;
}
Add this to your css
ul.firstnavmenu li ul{
margin-top:-3px;
}
Demo

Targeting an element by hovering another element in CSS

How can I target one element on hover and then effect an other element?
Here's the HTML:
<header>
<h1 style="float: left; margin-top: 2%;"> Naughty Mama.</h1>
<nav>
<ul>
<li>My Profile</li>
<li>Inbox</li>
<li>Notifications</li>
</ul>
</nav>
</header>
Here's the CSS:
#CHARSET "ISO-8859-1";
header {
background-color: #ddd;
}
nav {
float: right;
margin-right: 5%;
margin-top: 2%;
}
nav ul li{
display: inline;
padding: 15px;
background-color: #eee;
}
nav ul li a {
color: #fff;
text-decoration: none;
}
nav ul li a:hover {
color: #000;
}
I want to effect the nav ul li when I hover on nav ul li a.
Hope I am clear.
You may style <a> so it covers <li>. apply hover effect as background to <a> :)
http://codepen.io/anon/pen/zyDLA
header {
background-color: #ddd;
}
nav {
float: right;
margin-right: 5%;
margin-top: 2%;
}
nav ul li{
display: inline-block;
background-color: #eee;
vertical-align:top;
}
nav ul li a {
color: #fff;
text-decoration: none;
display:block;
padding:15px;
}
nav ul li a:hover {
color: #000;
background:#48a
}

Making a dropdown menu visible only on hover

I have been searching the internet. This question Hovering <a> in CSS without href on Stack Overflow, doesn't address my issue in a way I can understand.
I am trying to make a "primary" menu, with no links.
From each item in the menu, I'd like to create a drop down menu when hovering or clicking upon the item.
I would like to do this with CSS only.
I am having confusion. I have tried various permutations with z-index, positioning and visibility. However, I am finding it hard to achieve the result I need. I have also tried having links in the outside list items.
This is my code:
HTML:
<ul>
<li>Name 1
<ul>
<li>anteater</li>
<li>bee</li>
<li>cat</li>
<li>dog</li>
</ul>
</li>
<li>Name 2
<ul>
<li>egg</li>
<li>fern</li>
<li>goose</li>
<li>house</li>
</ul>
</li>
</ul>
CSS:
ul {
list-style-type: none;
margin: 0;
padding: 0;
}
li {
float: left;
padding: 30px 15px 20px 15px;
border-right: dotted #FFFFFF 1px;
color: #FFFFFF;
font-size: 11px;
position: relative;
z-index: 3;
}
li.end {
float: right;
}
a {
display: block;
text-decoration: none;
}
a:link {
color: #FFFFFF;
}
a:visited {
color: #FFFFFF;
}
a:hover {
color: #0099FF;
}
a:active {
color: #FFFFFF;
overflow: visible;
}
ul li:active ul, ul ul {
visibility:visible;
}
ul li:active ul, ul ul li {
visibility:visible;
}
ul li:hover ul, ul ul {
visibility: visible;
}
ul li:hover ul, ul ul li {
visibility:visible;
}
ul ul {
list-style-type: none;
margin: 0;
position: absolute;
visibility: hidden;
z-index:-1;
}
ul ul li {
float: left;
padding: 5px 10px;
border-right: dotted #0000FF 1px;
background-color: #000000;
color: #FFFFFF;
font-size: 11px;
position: relative;
visibility:hidden;
}
ul ul li a {
display: block;
text-decoration: none;
}
ul ul li a:link {
color: #0000FF;
}
ul ul li a:visited {
color: #0000FF;
}
ul ul li a:hover {
color: #FFFFFF;
visibility:visible;
}
ul ul li a:active {
color: #FFFFFF;
overflow: visible;
visibility:visible;
}
See this example http://jsfiddle.net/La2L8/
I think you have excessive CSS code

Drop down menu button isn't coloured fully and there are strange gaps in between

I'm trying to fix my drop down menu but I'm having problems with the highlighted colour and the background colour/size.
When I hover it, it is not covering the full button with orange like I want it to and, it has some grey left in it from the background where I don't want it to be.
One of the issues may be the fact I'm using 2 style sheets for mobile and computer.
HTML:
<div id="nav">
<ul id="menu">
<li id="active">Home</li>
<li>About Revelstoke</li>
<li>Ticker Rates</li>
<li>Snow School
<ul id="sub-menu">
<li>Kids Lessons</li>
<li>Adult Lessons</li>
<li>First Tracks</li>
</ul>
</li>
<li>Weather</li>
<li>Gallery</li>
<li>Trail Maps</li>
<li>Contact Us</li>
</ul>
</div><!--close nav-->
CSS (computer):
#nav {
background-color:#eee;
height: 33px;
border-top: solid black 2px;
border-bottom: solid black 2px;
min-width: 1000px;
}
#nav #active a {
font-weight: bold;
color: #ffffff;
background-color: #0160a2;
padding: 5px 15px 8px 15px;
}
#nav ul {
text-align: left;
font-size: 18px;
background-color: #eee;
}
#nav ul li {
display: block;
position: relative;
float: left;
line-height: 24px;
}
#nav ul li a {
display:inline;
padding:5px 10px 8px 10px;
background-color: #eee;
}
#nav li ul {
display: none;
}
#nav li:hover ul {
display: block;
position: absolute;
margin-top: 6px;
padding: 0;
width: 97px;
height: 82px;
}
#nav li:hover li {
font-size: 14px;
}
#nav ul li a:hover {
background-color: #ff8a00;
color: #000000;
}
#nav ul li ul li a{
padding:5px;
}
#nav ul li ul li a:hover{
padding:5px;
width: 97px;
height: 82px;
}
CSS (mobile):
#nav {
background-color:#eee;
}
#nav ul {
text-align:center;
font-size: 18px;
}
#nav ul li {
list-style-type:none;
border-top: 3px solid white;
}
#nav ul li a {
color: #000000;
display:block;
padding:13px 0;
text-decoration:none;
font-weight: bold;
}
#nav ul li a:hover {
background-color: #0096ff;
font-weight: bold;
color: white;
}
#nav #active a {
background-color: #01385e;
font-weight: bold;
color: white;
}
If I understood your question this should be a solution http://jsfiddle.net/GcDGv/2/ (I worked only for non-mobile CSS), this is how I fixed it:
I removed all height properties from classes related to the sub-menu. They can be auto-calculated.
Change the width of li elements in sub-menu to 100%, so now they will use whole area.
Make links in sub-menu as block elements, so margin/paddings from top and bottom will work as you want. And removed width and height properties from last style ul li ul li a:hover