i'm trying to add an effect to a mega menu. (it's under the health tab) when you hover over a link on the left, a section on the right is supposed to appear. looking at other stack overflow examples i found that if i used a:hover + div to make the div display, that should work, but for some reason it isn't. some assistance would be greatly appreciated!
#import url("http://fonts.googleapis.com/css?family=Roboto");
/* mini reset */
.nav,
.nav a,
.nav ul,
.nav li,
.nav div,
.nav form,
.nav input {
border: none;
margin: 0;
outline: none;
padding: 0;
}
.nav a {
text-decoration: none;
}
.nav li {
list-style: none;
}
/* menu container */
.nav,
input {
font-family: "Roboto", "Helvetica Neue", Helvetica, Arial, sans-serif;
font-size: 14px;
}
.nav {
cursor: default;
display: inline-block;
position: relative;
z-index: 500;
}
/* menu list */
.nav > li {
display: block;
float: left;
}
/* menu links */
.nav > li > a {
background: #0a64a2;
border-left: 1px solid #0f8ee2 !important;
display: block;
color: #fcfcfc;
font-weight: bold;
height: 54px;
line-height: 54px;
padding: 0 20px;
position: relative;
text-shadow: 0 0 1px rgba(0,0,0,.35);
-webkit-transition: all .3s ease;
transition: all .3s ease;
z-index: 510;
}
.nav > li:hover > a {
background: #8cbd3a;
}
.nav > li:first-child > a {
border-left: none;
border-radius: 3px 0 0 3px;
}
/* search form */
.nav > li.nav-search > form {
border-left: 1px solid #0f8ee2;
height: 54px;
position: relative;
width: inherit;
z-index: 510;
}
.nav > li.nav-search input[type="text"] {
background: #0a64a2;
display: block;
font-weight: bold;
font-size: 14px;
float: left;
height: 54px;
line-height: 24px;
padding: 15px 0 !important;
text-shadow: 0 0 1px rgba(0,0,0,.35);
-webkit-transition: all .3s ease 1s;
transition: all .3s ease 1s;
width: 1px;
color: #ebebeb;
}
.nav > li.nav-search input[type="text"]:focus {
color: #fcfcfc;
border:none;
box-shadow: none;
}
.nav > li.nav-search input[type="text"]:focus,
.nav > li.nav-search:hover input[type="text"] {
padding: 15px 20px !important;
-webkit-transition: all .3s ease .1s;
transition: all .3s ease .1s;
min-width: 110px;
width: 60%;
color: #ebebeb;
}
.nav > li.nav-search input[type="submit"] {
background: #0a64a2 url(../img/search-icon.png) no-repeat center center;
border-radius: 0 3px 3px 0;
cursor: pointer;
display: block;
float: left;
height: 54px;
padding: 0 25px;
-webkit-transition: all .3s ease;
transition: all .3s ease;
width: 20px;
}
.nav > li.nav-search input[type="submit"]:hover {
background-color: #4b4441;
}
/* menu dropdown */
.nav > li > div {
background: #fff;
border: 1px solid #ddd;
border-radius: 0 0 3px 3px;
position: absolute;
display: block;
left: 0;
opacity: 0;
overflow: hidden;
top: 50px;
-webkit-transition: all .3s ease .15s;
transition: all .3s ease .15s;
visibility: hidden;
width: 100%;
}
.nav > li:hover > div {
opacity: 1;
overflow: visible;
visibility: visible;
}
/* menu content styles */
.nav .nav-column {
float: left;
padding: 2.5%;
width: 25%;
}
.nav .nav-column h3 {
color: #372f2b;
font-size: 14px;
font-weight: bold;
line-height: 18px;
margin: 20px 0 10px 0;
text-transform: uppercase;
}
.nav .nav-column h3.orange {
color: #ff722b;
}
.nav .nav-column li a {
color: #888;
display: block;
font-weight: bold;
line-height: 26px;
}
.nav .nav-column li a:hover {
color: #8cbd34;
}
.nav a:hover > .menuheader {
color: #8cbd3a;
}
.nav a p {
color: black;
font-weight: normal;
}
.menuheader {
font-weight: bold !important;
margin-bottom: 0px;
margin-top: 5px;
font-size: 1.2em;
line-height: 18px;
}
.nav-column.info {
width: 75%;
}
.nav-column.info a {
display: none !important;
}
.healthlink1:hover + .healthinfo1 {
display: block !important;
}
<link href="https://dhbhdrzi4tiry.cloudfront.net/cdn/sites/foundation.min.css" rel="stylesheet"/>
<div class="menu-wrapper">
<ul class="nav">
<li>item</li>
<li>item</li>
<li>Health
<div>
<div class="nav-column left">
<ul>
<li class="healthlinks">
Asthma
Birth Defects
Cancer
Carbon Monoxide Poisoning
COPD
Heart Attacks
Heat Related Illness
Lead Poisoning
Oral Health
Reproductive Outcomes
</li>
</ul>
</div><!-- /nav-column -->
<div class="nav-column info left">
<ul>
<li>
Asthma info
Birth Defects info
Cancer info
Carbon Monoxide Poisoning info
COPD info
Heart Attacks info
Heat Related Illness info
Lead Poisoning info
Oral Health info
Reproductive Outcomes info
</li>
</ul>
</div><!-- /nav-column -->
</div>
</li>
<li>item</li>
<li>item</li>
<li>item</li>
</ul>
</div>
.nav-column.info a {
display: none !important;
}
Issue with display: none !important;
Just remove it from css style and right div will be displayed.
https://jsfiddle.net/cyhog5ra/
ok so i found foundation 6 and it does exactly what i needed so to help anyone else who has this problem here's something that works!`
$(document).ready(function() {
$(document).foundation();
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/foundation/6.0.1/js/vendor/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/foundation/6.0.1/js/foundation.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/foundation/6.0.1/css/foundation.css">
<div class = "row collapse">
<div class = "medium-3 columns">
<ul class = "tabs vertical" data-tabs id = "tabs_example">
<li class = "tabs-title is-active">text 1</li>
<li class = "tabs-title">text 2</li>
<li class = "tabs-title">text 3</li>
<li class = "tabs-title">text 4</li>
<li class = "tabs-title">text 5</li>
</ul>
</div>
<div class = "medium-9 columns">
<div class = "tabs-content vertical" data-tabs-content = "tabs_example">
<div class = "tabs-panel is-active" id = "tab1">
<p>First text</p>
</div>
<div class = "tabs-panel" id = "tab2">
<p>Second text</p>
</div>
<div class = "tabs-panel" id = "tab3">
<p>Third text</p>
</div>
<div class = "tabs-panel" id = "tab4">
<p>Fourth text</p>
</div>
<div class = "tabs-panel" id = "tab5">
<p>Five text</p>
</div>
</div>
</div>
`
Related
Hello please I need some help with making a child sub-menu to be visible when I mouse hover on the "Accesorii Gaming", its child sub-menu is:
Ochelari VR Gaming
Gamepad / Controler
Volane
Casti Console
Streaming
and it should be visible on hover. I am doing a CSS battle here and I think I am loosing it...
Thank you for your support
HTML + CSS3 is here: https://codepen.io/tosasilviu/pen/vYBMWyM
or below...
* {
margin: 0;
padding: 0;
}
li {
list-style: none;
}
.font-produse-h {
font-family: "Bungee";
font-size: 45px;
text-shadow: 3px 3px 0px #08b870;
color: #000;
margin: 50px 0 20px 50px;
}
/* Menu Container */
.navigation {
display: inline-block;
position: relative;
z-index: 10;
margin-left: 50px;
}
/* Menu List */
.navigation > li {
display: block;
float: left;
}
/* Menu Links */
.navigation > li > a {
position: relative;
display: block;
z-index: 20;
width: 130px;
height: 54px;
padding: 0 20px;
line-height: 54px;
font-family: "Quicksand";
font-weight: bold;
font-size: 15px;
color: #fcfcfc;
text-shadow: 0 0 1px rgba(0, 0, 0, 0.35);
background: #08b870;
border-left: 1px solid #06e187;
text-align: center;
-webkit-transition: all 0.3s ease;
-moz-transition: all 0.3s ease;
-o-transition: all 0.3s ease;
-ms-transition: all 0.3s ease;
transition: all 0.3s ease;
}
.navigation > li:hover > a {
background: #0b8452;
}
.navigation > li:first-child > a {
border-radius: 6px 0px 0px 6px;
border-left: 0px;
}
.navigation > li:last-child > a {
border-radius: 0px 6px 6px 0px;
}
/* Menu Dropdown */
.navigation > li > div {
position: absolute;
display: block;
color: #fff;
width: 170px;
top: 50px;
opacity: 0;
visibility: hidden;
overflow: hidden;
background: #0b8452;
border-radius: 0 0 3px 3px;
-webkit-transition: all 0.3s ease 0.15s;
-moz-transition: all 0.3s ease 0.15s;
-o-transition: all 0.3s ease 0.15s;
-ms-transition: all 0.3s ease 0.15s;
transition: all 0.3s ease 0.15s;
}
/* Menu Dropdown Child */
.navigation-child {
position: absolute;
width: 170px;
left: 170px;
top: 74px;
display: none;
}
.navigation-column-child {
color: #fff;
text-decoration: none;
font-size: 15px;
font-weight: bold;
font-family: "Quicksand";
display: block;
padding: 17px 0 17px 0;
text-align: center;
border-bottom: 1px solid #085b39;
}
.navigation-column-link {
color: #fff;
text-decoration: none;
font-size: 15px;
font-weight: bold;
font-family: "Quicksand";
display: block;
padding: 17px 0 17px 0;
text-align: center;
border-bottom: 1px solid #085b39;
}
li:hover > a {
background: #045030;
}
.navigation-column {
margin-top: 20px;
}
.navigation > li:hover > div {
opacity: 1;
visibility: visible;
overflow: visible;
}
<!DOCTYPE html>
<html lang="ro">
<head>
<title>Meniu CSS Dropdown</title>
<link rel="stylesheet" href="css/style.css" />
<link href="https://fonts.googleapis.com/css?family=Bungee&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Quicksand&display=swap" rel="stylesheet">
</head>
<body>
<h1 class="font-produse-h">Produse</h1>
<ul class="navigation">
<li>
Gaming
<div>
<div class="navigation-column">
<ul>
<li><a class="navigation-column-link" href="#">Console Gaming</a></li>
<li><a class="navigation-column-child" href="#">Accesorii Gaming</a>
<ul class="navigation-child">
<li><a class="navigation-column-link" href="#">Ochelari VR Gaming</a></li>
<li><a class="navigation-column-link" href="#">Gamepad / Controler</a></li>
<li><a class="navigation-column-link" href="#">Volane</a></li>
<li><a class="navigation-column-link" href="#">Casti Console</a></li>
<li><a class="navigation-column-link" href="#">Streaming</a></li>
</ul>
</li>
<li><a class="navigation-column-link" href="#">Scaune Gaming</a></li>
<li><a class="navigation-column-link" href="#">Licente Electronice</a></li>
<li><a class="navigation-column-link" href="#">Jocuri Console & PC</a></li>
<li><a class="navigation-column-link" href="#">PC Gaming</a></li>
<li><a class="navigation-column-link" href="#">Accesorii PC</a></li>
<li><a class="navigation-column-link" href="#">Resigilate</a></li>
</ul>
</div>
</div>
</li>
<li>Gaming 2</li>
<li>Gaming 3</li>
<li>Gaming 4</li>
<li>Gaming 5</li>
</ul>
</body>
</html>
You are on the right path. You can go deeper in the css selector to make a hover statement on each navigation item and change whatever code you want from there to display the child ul. Simple example below:
.navigation li ul li:hover ul {
display: block;
}
NOTE: THE NAVBAR IS NOT IN BOOTSTRAP
Okay, so, when I hover over my "More" button, it displays dropdown content but it just suddently appears and when I move my mouse somewhere else it suddently disappears. What I want, is to make the dropdown content appear through a transition or something like that. Here is my code:
<nav>
<ul>
<li>Home</li>
<li>Earn Coins</li>
<li>Get Rewards</li>
<li>Referrals</li>
<li>Vouchers</li>
<li><div class="dropdownd">
More
<i class="fa fa-caret-down"></i>
<div class="dropdown-contentd">
<a class="dropdowncontentn" href="leaderboard.php">Leaderboard</a>
<a class="dropdowncontentn" href="partnerships.php">Partnerships</a>
<a class="dropdowncontentn" href="contact.php">Contact us</a>
<a class="dropdowncontentn" href="socialmedia.php">Social Media</a>
<a class="dropdowncontentn" href="settings.php">Settings</a>
</div>
</div> </li>
<li>
<a href="#">
<i class="fa fa-bars"></i>
</a>
</li>
<li class="thum" style="float:right;margin-right:25px;">
<a onClick="navbar_coins_refresh.php" href="#" class="coinsnumber"><?php include 'navbar_coins.php'; ?></a>
</li>
</ul>
</nav>
# CSS #
* {
box-sizing:border-box;
-o-box-sizing:border-box;
-ms-box-sizing:border-box;
-moz-box-sizing:border-box;
-webkit-box-sizing:border-box;
}
nav ul li a {
color: #FFF;
text-decoration: none;
font-size: 16px;
-webkit-transition-duration: 0.4s;
transition-duration: 0.4s;
padding: 15px;
font-family: Ubuntu;
}
nav ul li a:hover {
text-decoration: none;
color: #444;
}
nav ul li a.coinsnumber:hover {
text-decoration: none;
color: white;
}
.dropdown-contentd {
display: none;
position: absolute;
top: 49px;
background-color: royalblue;
color: #FFF;
min-width: 160px;
box-shadow: 0 8px 16px 0 rgba(0,0,0,0.2), 0 6px 20px 0 rgba(0,0,0,0.19);
z-index: 1;
/*border: 1px solid black;*/
margin: 0;
padding: 0;
padding-top: 10px;
padding-bottom: 10px;
transition: all .3s ease;
}
.dropdown-contentd a {
float: none;
color: black;
padding: 12px 16px;
color: #ffffff;
text-decoration: none;
display: block;
text-align: left;
transition: all .3s ease;
background-color: royalblue;
}
.dropdown-contentd a:hover {
color: #444;
}
.dropdownd:hover .dropdown-contentd {
display: block;
}
/* End General */
/* Start Navbar */
nav ul {
background-color: royalblue;
box-shadow: 0 8px 16px 0 rgba(0,0,0,0.2), 0 6px 20px 0 rgba(0,0,0,0.19);
}
nav ul > li {
padding-left: 20px;
padding-right: 20px;
padding: 15px;
display: inline-block;
transition: all .3s ease;
margin-left: -5px
}
nav ul > ol {
position: absolute;
top: 49px;
right: 0;
background: #333;
text-align: center;
list-style: none;
display: none
}
nav ul > ol > li {
width: 100vw;
color: #FFF;
margin: 0;
padding: 0;
padding-top: 10px;
padding-bottom: 10px;
transition: all .3s ease;
}
nav ul > ol > li:hover a {
margin: 20px;
}
nav ul > ol > li:hover {
background: #000;
cursor: pointer
}
nav ul input {
opacity: .7;
padding: 5px;
float: right;
display: none
}
/* Start Menue Right */
/* Start Media Query */
#media screen and (max-width:950px){
nav ul > li:not(:first-child) {
display:none;
}
nav ul > li:nth-last-of-type(2) {
display: inline-block;
}
nav ul > li:last-of-type {
display: inline-block;
}
}
#media screen and (min-width:950px) {
nav ul > ol > li {
display:none
}
nav ul > li:nth-last-of-type(2) {
display: none
}
}
.dropdowncontentn {
background-color: royalblue;
}
nav {
z-index: 1;
position: fixed;
right: 0;
left: 0;
top: 0;
}````
It's common question. You have to use max-height transition, not just height. Check here How can I transition height: 0; to height: auto; using CSS?
Could someone explain to me why navigating away from the main menu item causes the sub-menu to vanish? And possibly provide a fix. My google-foo skills are below par this morning. Thanks all.
CSS:
body, html{
margin: 0;
}
.content{
padding: 30px;
}
.nav-main{
width: 100%;
background-color: #222;
height: 70px;
color: #fff;
}
.nav-main > ul{
margin: 0;
padding: 0;
float: left;
list-style-top: none;
}
.nav-main > ul > li {
float: left;
}
.nav-item {
display: inline-block;
padding: 15px 20px;
height: 40px;
line-height: 40px;
color: #fff;
text-decoration: none;
}
.nav-item:hover{
background-color: #444;
}
.nav-content{
position: absolute;
top: 70px;
overflow: hidden;
background-color: #222; /* same color as main nav*/
max-height: 0; /*will not display if .nav-content no padding */
}
.nav-content a{
color: #fff;
text-decoration: none;
}
.nav-content a:hover{
text-decoration: underline;
}
.nav-sub{
padding: 20px;
}
.nav-sub ul{
padding: 0;
margin: 0;
list-style-type: none;
}
.nav-sub > ul > li{
display: inline-block;
}
.nav-sub ul li a{
padding: 5px 0;
}
.nav-item:focus{
background-color: #444; /*remove if click focus not necessary*/
}
.nav-item:hover ~ .nav-content{
max-height: 400px;
-webkit-transition:max-height 0.6s ease-in;
-moz-transition:max-height 0.6s ease-in;
transition:max-height 0.6s ease-in;
}
HTML:
<body>
<nav class="nav-main">
<ul>
<li>
first
<div class="nav-content">
<div class="nav-sub">
<ul>
<li>this is a thing</li>
<li>this is a thing 2</li>
</ul>
</div>
</div>
</li>
<li>
second
</li>
<li>
third
</li>
</ul>
</nav>
<div class="content">this is content</div>
</body>
I have changed:
.nav-item:hover ~ .nav-content{
To
nav > ul > li:hover > .nav-content{
And now it's working - example:
https://jsfiddle.net/saxkayv2/
I have a pre-existing responsive menu but I need to add a sub-navigation for each menu choice. How can I do this with CSS?
The important code, I think, is in the section primary navigation.
Thank you in advance for everyone that can help me to understand how sub-menus work.
/**
/* 06. =header styles
/* =================================================================== */
html,
body {
height: 100%;
}
body {
background: #0F1215;
font: 16px/30px "merriweather-regular", serif;
font-weight: normal;
color: #575859;
}
header {
height: 66px;
width: 100%;
position: fixed;
left: 0;
top: 0;
z-index: 600;
-moz-transition: all 0.5s ease-in-out;
-o-transition: all 0.5s ease-in-out;
-webkit-transition: all 0.5s ease-in-out;
-ms-transition: all 0.5s ease-in-out;
transition: all 0.5s ease-in-out;
}
header.opaque {
background: black;
border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
/* header logo */
header .logo {
background: #fdc501;
float: left;
width: auto;
margin-left: 15px;
margin-right: 30px;
z-index: 600;
/* add position relative since z-index only applies to
elements that have been given an explicit position */
position: relative;
}
header .logo a {
display: block;
margin: 0;
padding: 0;
border: none;
font: 0/0 a;
text-shadow: none;
color: transparent;
width: 114px;
height: 66px;
background: url("../images/logoK#2x.png") no-repeat center;
background-size: 61px 14px;
}
/* header social */
header .header-social {
font-size: 20px;
font-weight: normal;
line-height: 66px;
margin-top: 0;
margin-left: 30px;
padding-left: 36px;
border-left: 1px solid rgba(150, 150, 150, 0.2);
float: left;
position: relative;
top: -1px;
}
header .header-social li {
display: inline-block;
margin-right: 15px;
}
header .header-social li a {
color: #FFFFFF;
}
header .header-social li a:hover {
color: #fdc501;
}
/* media queries:
/* header/header components */
#media only screen and (max-width:880px) {
header .header-social {
display: none;
}
}
#media only screen and (max-width:768px) {
header {
background: black;
border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
header .row {
width: 100%;
}
header .logo {
margin-left: -30px;
}
}
/* primary navigation
--------------------------------------------------------------------- */
#nav-wrap,
#nav-wrap ul,
#nav-wrap li,
#nav-wrap a {
margin: 0;
padding: 0;
}
/* nav-wrap */
#nav-wrap {
font: 13px "raleway-heavy", sans-serif;
text-transform: uppercase;
letter-spacing: 1.5px;
float: left;
}
/* hide toggle button */
#nav-wrap > a {
display: none;
}
ul#nav {
min-height: 66px;
display: inline-block;
width: auto;
/* left align the menu */
text-align: left;
}
ul#nav li {
position: relative;
list-style: none;
display: inline-block;
height: 66px;
}
/* Links */
ul#nav li a {
/* 14px padding top + 14px padding bottom + 38px line-height = 66px */
display: block;
padding: 14px 12px;
line-height: 38px;
text-decoration: none;
text-align: left;
color: #FFFFFF;
position: relative;
-moz-transition: color 0.2s ease-in-out;
-o-transition: color 0.2s ease-in-out;
-webkit-transition: color 0.2s ease-in-out;
-ms-transition: color 0.2s ease-in-out;
transition: color 0.2s ease-in-out;
}
ul#nav li a:hover {
color: #fdc501;
}
ul#nav li a:active {
background-color: transparent !important;
}
ul#nav li.current a {
color: #fdc501;
}
ul#nav li.current a:after {
position: absolute;
left: 50%;
bottom: 0;
width: 40px;
height: 2px;
margin-left: -23px;
background-color: white;
content: '\0020';
display: block;
-moz-transition: all 0.3s ease-in-out;
-o-transition: all 0.3s ease-in-out;
-webkit-transition: all 0.3s ease-in-out;
-ms-transition: all 0.3s ease-in-out;
transition: all 0.3s ease-in-out;
}
/* mobile navigation
--------------------------------------------------------------------- */
#media only screen and (max-width:768px) {
#nav-wrap {
z-index: 700;
display: block;
width: 100%;
float: none;
position: absolute;
top: 0;
right: 0;
}
/* mobile-btn and toggle-btn */
#nav-wrap > a {
border: none;
color: #FFFFFF;
height: 40px;
min-width: 40px;
font-size: 12px;
text-align: left;
float: right;
display: block;
padding: 0;
position: relative;
top: 13px;
right: 20px;
}
#nav-wrap > a:hover .menu-icon {
background: #FFFFFF;
}
#nav-wrap .menu-icon {
display: inline-block;
width: 24px;
height: 3px;
margin-top: -3px;
position: absolute;
right: 8px;
top: 50%;
bottom: auto;
left: auto;
background: #fdc501;
-moz-transition: all 0.3s ease-in-out;
-o-transition: all 0.3s ease-in-out;
-webkit-transition: all 0.3s ease-in-out;
-ms-transition: all 0.3s ease-in-out;
transition: all 0.3s ease-in-out;
font: 0/0 a;
text-shadow: none;
color: transparent;
}
#nav-wrap .menu-icon:before,
#nav-wrap .menu-icon:after {
content: '';
width: 100%;
height: 100%;
position: absolute;
background-color: inherit;
left: 0;
}
#nav-wrap .menu-icon:before {
bottom: 8px;
}
#nav-wrap .menu-icon:after {
top: 8px;
}
/* dropdown nav */
#nav-wrap ul#nav {
background: #1c212a;
padding: 54px 45px 60px 45px;
margin: 0;
height: auto;
display: none;
clear: both;
width: 100%;
float: none;
position: absolute;
top: 66px;
right: 0;
}
#nav-wrap ul#nav > li {
display: block;
float: none;
height: auto;
text-align: left;
border-bottom: 1px dotted rgba(200, 200, 200, 0.1);
padding: 6px 0;
}
#nav-wrap ul#nav > li:first-child {
border-top: 1px dotted rgba(200, 200, 200, 0.1);
}
#nav-wrap ul#nav li a {
display: block;
width: auto;
padding: 0;
color: #cacbcb;
padding: 12px 0;
line-height: 16px;
border: none;
}
#nav-wrap ul#nav li a:hover {
color: #FFFFFF;
}
#nav-wrap ul#nav li.current > a {
background: none;
color: #fdc501;
}
#nav-wrap ul#nav li.current > a:after {
display: none;
}
#nav-wrap a.mobile-btn {
display: none;
}
.js #nav-wrap a#toggle-btn {
display: block;
}
/* if js is disabled */
.no-js #nav-wrap:not(:target) > a:first-of-type,
.no-js #nav-wrap:target > a:last-of-type {
display: block;
}
.no-js #nav-wrap:target ul#nav {
display: block;
}
}
/* make sure the menu is visible on larger screens
--------------------------------------------------------------------- */
#media only screen and (min-width:769px) {
#nav-wrap ul#nav {
display: block !important;
}
}
<header id="main-header">
<div class="row">
<div class="logo">
SAT | Aloia Evelina
</div>
<nav id="nav-wrap">
<a class="mobile-btn" href="#nav-wrap" title="Show navigation">
<span class="menu-icon">Menu</span>
</a>
<a class="mobile-btn" href="#" title="Hide navigation">
<span class="menu-icon">Menu</span>
</a>
<ul id="nav" class="nav">
<li><a class="smoothscroll" href="#hero">Home.</a></li>
<li class="current"><a class="smoothscroll" href="#portfolio">Works.</a></li>
<li><a class="smoothscroll" href="#services">Services.</a></li>
<li><a class="smoothscroll" href="#about">About.</a></li>
<li><a class="smoothscroll" href="#contact">Contact.</a></li>
</ul> <!-- end #nav -->
</nav> <!-- end #nav-wrap -->
<ul class="header-social">
<li><i class="fa fa-facebook"></i></li>
<li><i class="fa fa-twitter"></i></li>
<li><i class="fa fa-google-plus"></i></li>
</ul>
</div>
</header> <!-- end header -->
<ul id="nav" class="nav">
<li><a class="smoothscroll" href="#hero">Home.</a>
<ul>
<li>#item1</li>
<li>#item1</li>
</ul>
</li>
<li class="current"><a class="smoothscroll" href="#portfolio">Works.</a>
<ul>
<li>#item1</li>
<li>#item1</li>
</ul>
</li>
<li><a class="smoothscroll" href="#services">Services.</a>
<ul>
<li>#item1</li>
<li>#item1</li>
</ul>
</li>
<li><a class="smoothscroll" href="#about">About.</a>
<ul>
<li>#item1</li>
<li>#item1</li>
</ul>
</li>
<li><a class="smoothscroll" href="#contact">Contact.</a>
<ul>
<li>#item1</li>
<li>#item1</li>
</ul>
</li> </ul>
in your html file you code should look something like this.
and then for more details on how you can style your code you can visit the site https://css-tricks.com/targetting-menu-elements-submenus-navigation-bar/
It provides some tricks in which you can style your menu as well as I how the html file should look like. I find it very much helpfull.
I am looking for help on this navigation bar, I need it to be able to drop down while keeping the other items of the navigation bar in place. I have looked through all of the other submissions and still didn't find anything that helped. Here is the code and example.
http://jsfiddle.net/doctor_turkey/G2xfz/
<html>
<style>
#div5 {
background-color: black;
-webkit-box-shadow: 0px 0px #000000;
box-shadow:0px 5px 5px #5B5454;
width: 100%;
clear: both;
margin-left: -1%;
margin-right:-1%;
padding-left:1%;
padding-right:1%;
}
#div5 ul{
margin: 0 0 0 60px;
padding: 0px;
list-style: none;
}
#div5 ul li{
display: inline;
-webkit-box-shadow: 0px 0px #000000;
box-shadow: 0px 0px #000000;
position:relative;
}
#div5 ul li a{
float: left;
width: 15%;
height: 20px;
margin-top: -5px;
margin-bottom: 10px;
padding: 0;
font-size: 15px;
font-weight: none;
text-align: center;
text-decoration: none;
color: black;
border-left: 1px solid #CCCCCC;
border-right: 1px solid #CCCCCC;
font-family: "Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", "DejaVu Sans", Verdana, sans-serif;
}
#div5 ul li .firstmenu{
border-left: 2px solid #CCCCCC;
border-right: 1px solid #CCCCCC;
-webkit-box-shadow: 0px 0px;
box-shadow: 0px 0px;
}
#div5 ul li .smallmenuend{
border-left: 1px solid #CCCCCC;
border-right: 2px solid #CCCCCC;
}
/* HOVER MENU TEST*/
#div5 li ul {
float: left;
left: 0;
opacity: 0;
position:relative;
display:none;
z-index: 1;
-webkit-transition: all .25s ease;
-moz-transition: all .25s ease;
-ms-transition: all .25s ease;
-o-transition: all .25s ease;
transition: all .25s ease;
}
#div5 li:hover ul {
opacity: 1;
/* top: 50px;*/
display:block;
float: left;
color:black;
clear:left;
display:block;
margin-left:20%;
}
#div5 li ul li {
clear:left;
color:black;
display:block;
width:100%;
}
#div5 li ul li a{
width:100%;
}
#div5 li ul a:hover {
background: #bbb;
}
</style>
<div id="div5" class="fluid">
<p align="center">
<div align="center">
<ul>
<li> One</li>
<li> Two
<ul>
<li> Test 1 </li>
<li> Test 2 </li>
</ul>
</li>
<li><a href="#" >Three</a></li>
<li> Four </li>
<li>Five</li>
<li >Six</li>
</ul>
</div>
</p>
</div>
Your code needs a lot of work - it is a soup of unnecessary markup and styles.
Here's a cleaned up version of this navigation bar. You are welcome to study this code and optimize yours.
HTML:
<ul id = "nav">
<li>Home</li>
<li>Energy
<ul>
<li>Test 1</li>
<li>Test 2</li>
</ul>
</li>
<li>Account</li>
<li>Contact</li>
<li>Services</li>
<li >Solutions</li>
</ul>
CSS:
* {
margin: 0;
padding: 0;
}
body {
background-color: #eee;
}
#nav {
list-style-type: none;
display: table;
min-width: 610px;
margin: 0 auto;
background-color: #fff;
text-align: center;
}
#nav > li {
display: inline-block;
position: relative;
}
#nav ul {
list-style-type: none;
background-color: #5f6975;
position: absolute;
min-width: 100%;
}
#nav li a {
font: normal 15px/1 Sans-Serif;
text-decoration: none;
color: #4b545f;
display: block;
padding: 10px 20px;
text-align: left;
white-space: nowrap;
}
#nav ul a {
color: #fff;
}
#nav ul > li + li {
border-top: 1px solid #6b727c;
}
#nav li:hover {
background-color: #4b545f;
}
#nav > li:hover > a {
color: #fff;
}
#nav ul {
display: none;
}
#nav li:hover > ul {
display: block;
}
And, a fiddle: http://jsfiddle.net/bE2D2/.