I would like to know how to highlight each menu item in the following drop down menu. When I hover over the current menu with mouse it highlights the | characters also next to them. How can I solve this? Thank you for all information.
The html code is :
#menu {
width: 960px;
margin-left: auto;
margin-right: auto;
text-align: center;
position: relative;
z-index: 1;
}
#primary_nav_wrap {
margin-left: auto;
margin-right: auto;
margin-top: 5px;
text-align: center;
/*margin-left:50px; */
}
#primary_nav_wrap ul {
list-style: none;
position: relative;
/*float:left;*/
text-align: center;
margin: 0;
padding: 0;
}
#primary_nav_wrap ul a {
/*display:block;*/
color: #333;
text-decoration: none;
font-weight: 500;
font-size: 14px;
text-transform: uppercase;
line-height: 32px;
padding-top: 10px;
font-family: 'Raleway', sans-serif;
display: inline-block;
}
#primary_nav_wrap ul li {
display: inline-block;
position: relative;
/*float:left;*/
margin: 0px;
padding: 0px;
}
#primary_nav_wrap ul li a {}
#primary_nav_wrap ul li a:after {
margin-left: 10px;
margin-right: 10px;
content: " | ";
}
#primary_nav_wrap ul li.last a:after {
content: none !important;
}
#primary_nav_wrap ul li li.submenu a:after {
content: none !important;
}
#primary_nav_wrap ul li a:hover {
background: #f6f6f6;
}
#primary_nav_wrap ul ul {
display: none;
position: absolute;
top: 100%;
left: 0;
background: #fff;
opacity: .8;
padding: 0;
}
#primary_nav_wrap ul ul li {
float: none;
text-align: left;
width: 200px;
}
#primary_nav_wrap ul ul a {
line-height: 120%;
padding: 10px 15px;
}
#primary_nav_wrap ul ul ul {
top: 0;
left: 100%;
}
#primary_nav_wrap ul li:hover ul {
display: inline-block;
}
<div id="menu">
<nav id="primary_nav_wrap">
<ul>
<li class="currentmenuitem">Home
</li>
<li>about us
</li>
<li>day course
<ul>
<li class="submenu">3 Day Course
</li>
<li class="submenu">6 Day Course
</li>
</ul>
</li>
<li>short course
<ul>
<li class="submenu">Pasta course
</li>
<li class="submenu">Pizza course
</li>
<li class="submenu">Fettucine course
</li>
</ul>
</li>
<li>Tours
</li>
<li>recipes
</li>
<li>reviews
</li>
<li>Contact Us
</li>
<li class="last">Location
</li>
</ul>
</nav>
</div>
Change the placement of your pseudo element from the a to li. Do this for all CSS selectors that are targeting the a.
Update #primary_nav_wrap ul li a:after {} to #primary_nav_wrap ul li:after {}
Below is an example of your menu with improved markup and reduced CSS (lot's of overlap of CSS properties that were not needed).
#menu {
width: 960px;
margin-left: auto;
margin-right: auto;
}
#primary_nav_wrap ul,
#primary_nav_wrap li {
margin: 0;
padding: 0;
list-style: none;
}
#primary_nav_wrap li {
display: inline-block;
position: relative;
}
#primary_nav_wrap a {
color: #333;
text-decoration: none;
font-weight: 500;
font-size: 14px;
text-transform: uppercase;
line-height: 32px;
font-family: 'Raleway', sans-serif;
display: inline-block;
}
#primary_nav_wrap a:hover {
background: #f6f6f6;
}
#primary_nav_wrap ul > li:after {
margin-left: 10px;
margin-right: 10px;
content: " | ";
}
#primary_nav_wrap ul > li:hover .submenu {
display: block;
}
#primary_nav_wrap .submenu > li {
float: none;
text-align: left;
width: 200px;
}
#primary_nav_wrap .submenu {
display: none;
position: absolute;
top: 100%;
left: 0;
background: #fff;
opacity: .8;
padding: 0;
}
#primary_nav_wrap ul > li.last:after,
#primary_nav_wrap .submenu > li:after {
content: none !important;
}
#primary_nav_wrap .submenu a {
line-height: 120%;
padding: 10px 15px;
}
<div id="menu">
<nav id="primary_nav_wrap">
<ul>
<li class="currentmenuitem">Home
</li>
<li>about us
</li>
<li>day course
<ul class="submenu">
<li>3 Day Course
</li>
<li>6 Day Course
</li>
</ul>
</li>
<li>short course
<ul class="submenu">
<li>Pasta course
</li>
<li>Pizza course
</li>
<li>Fettucine course
</li>
</ul>
</li>
<li>Tours
</li>
<li>recipes
</li>
<li>reviews
</li>
<li>Contact Us
</li>
<li class="last">Location
</li>
</ul>
</nav>
</div>
Related
My dropdown menu currently looks like this :
The Home is not quite at the correct position like how I would like it at the top left, how do I fix this? Many thanks for the help.
* {
margin: 0;
padding: 0;
}
nav {
width: 1600px;
}
ul {
list-style: none;
background-color: #333;
}
ul li {
width: 200px;
background: #333;
float: left;
height: 35px;
line-height: 35px;
text-align: center;
margin-right: 2px;
position: relative;
float: none;
display: inline-block;
}
ul li:hover {
background: #0e6ea8;
}
ul li a {
color: #fff;
text-decoration: none;
font-family: sans-serif;
display: block;
border: none;
}
ul li ul li {
border-top: 1px solid #fff;
}
ul li ul {
display: none;
}
ul li:hover ul {
display: block;
}
ul li ul .first {
position: absolute;
left: 201px;
top: 0;
display: none;
}
ul li ul :hover .first {
display: block;
}
ul li ul .second {
position: absolute;
left: 201px;
top: 0;
display: none;
}
ul li ul :hover .second {
display: block;
}
ul li ul li ul .seconda {
position: absolute;
left: 201px;
top: 0;
display: none;
}
ul li ul li ul:hover .seconda {
display: block;
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
<nav>
<div class="nav navbar-fixed-top">
<ul>
<li>Home</li>
<li>Options<span> ▾</span>
<ul>
<li><a href="#">Consumer
Management <span>▶</span></a>
<ul class="first">
<li>www.e-homes.com.my</li>
</ul>
</li>
<li><a href="#">Project Admin
Tool <span>▶</span></a>
<ul class="second">
<li>Download</li>
<ul class="seconda">
<li>Download MR</li>
<li>Download PO</li>
<li>Download Invoice
</li>
<li>Download lalalala
</li>
</ul>
</ul>
</li>
</ul>
</div>
</nav>
I know its just a small thing I missed, would appreciate some guidance on this thank you so much again.
You have a missing ul and li before the second last closing element.
Add d-flex on the ul after navbar-fixed-top element <div class="nav navbar-fixed-top"> <ul class="d-flex">
* {
margin: 0;
padding: 0;
}
nav {
width: 1600px;
}
ul {
list-style: none;
background-color: #333;
}
ul li {
width: 200px;
background: #333;
float: left;
height: 35px;
line-height: 35px;
text-align: center;
margin-right: 2px;
position: relative;
float: none;
display: inline-block;
}
ul li:hover {
background: #0e6ea8;
}
ul li a {
color: #fff;
text-decoration: none;
font-family: sans-serif;
display: block;
border: none;
}
ul li ul li {
border-top: 1px solid #fff;
}
ul li ul {
display: none;
}
ul li:hover ul {
display: block;
}
ul li ul .first {
position: absolute;
left: 201px;
top: 0;
display: none;
}
ul li ul :hover .first {
display: block;
}
ul li ul .second {
position: absolute;
left: 201px;
top: 0;
display: none;
}
ul li ul :hover .second {
display: block;
}
ul li ul li ul .seconda {
position: absolute;
left: 201px;
top: 0;
display: none;
}
ul li ul li ul:hover .seconda {
display: block;
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
<nav>
<div class="nav navbar-fixed-top">
<ul class="d-flex">
<li>Home</li>
<li>Options<span> ▾</span>
<ul>
<li><a href="#">Consumer
Management <span>▶</span></a>
<ul class="first">
<li>www.e-homes.com.my</li>
</ul>
</li>
<li><a href="#">Project Admin
Tool <span>▶</span></a>
<ul class="second">
<li>Download</li>
<ul class="seconda">
<li>Download MR</li>
<li>Download PO</li>
<li>Download Invoice
</li>
<li>Download lalalala
</li>
</ul>
</ul>
</li>
</ul>
</li>
</ul>
</div>
</nav>
Your HTML structure is incorrect (closing tags missing) and your CSS contains an error for ul li. Corrected below.
* {
margin: 0;
padding: 0;
}
nav {
width: 1600px;
}
ul {
list-style: none;
background-color: #333;
}
ul li {
width: 200px;
background: #333;
float: left;
height: 35px;
line-height: 35px;
text-align: center;
margin-right: 2px;
position: relative;
/* float: none; REMOVED */
display: inline-block;
}
ul li:hover {
background: #0e6ea8;
}
ul li a {
color: #fff;
text-decoration: none;
font-family: sans-serif;
display: block;
border: none;
}
ul li ul li {
border-top: 1px solid #fff;
}
ul li ul {
display: none;
}
ul li:hover ul {
display: block;
}
ul li ul .first {
position: absolute;
left: 201px;
top: 0;
display: none;
}
ul li ul :hover .first {
display: block;
}
ul li ul .second {
position: absolute;
left: 201px;
top: 0;
display: none;
}
ul li ul :hover .second {
display: block;
}
ul li ul li ul .seconda {
position: absolute;
left: 201px;
top: 0;
display: none;
}
ul li ul li ul:hover .seconda {
display: block;
}
<nav>
<div class="nav navbar-fixed-top">
<ul>
<li>Home</li>
<li>Options<span> ▾</span>
<ul>
<li><a href="#">Consumer
Management <span>▶</span></a>
<ul class="first">
<li>www.e-homes.com.my</li>
</ul>
</li>
<li><a href="#">Project Admin
Tool <span>▶</span></a>
<ul class="second">
<li>Download
<ul class="seconda">
<li>Download MR</li>
<li>Download PO</li>
<li>Download Invoice
</li>
<li>Download lalalala
</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
</nav>
I have 1 side menu in my main page of website. And some of the list have have sub menu. And on hover i want to display it. Firstly i am display it none and then on display it on hover but it is not displaying.
#menu {
width: 15%;
height: 100%;
background: #424242;
color: white;
float: left;
}
#menu ul {
margin: 0;
padding: 0;
}
#menu li {
list-style: none;
font-size: 20px;
padding: 15px 20px;
cursor: pointer;
}
#menu li:hover {
background-color: #90CAF9;
}
#menu li.active {
background-color: #2196F3;
}
#menu li ul {
display: none;
}
#menu li:hover ul {
display: block;
position: absolute;
left:100%
}
<div id="menu">
<ul>
<li onClick="Dashboard();">Dashboard</li>
<li>Employee >
<ul>
<li>Add Employee</li>
<li>Employee View</li>
</ul>
</li>
<li>Leave</li>
<li>Salary</li>
<li>Change Password</li>
</ul>
</div>
#menu {
width: 150px;
height: 100%;
background: #424242;
color: white;
float: left;
}
#menu ul {
margin: 0;
padding: 0;
}
#menu li {
list-style: none;
font-size: 20px;
padding: 15px 20px;
cursor: pointer;
}
#menu li:hover {
background-color: #90CAF9;
}
#menu li.active {
background-color: #2196F3;
}
#menu ul li ul {
display: none;
}
#menu ul li.submenu {
position: relative
}
#menu ul li.submenu ul {
position: absolute;
left: 150px;
width: 200px;
top: 0;
background: #333
}
#menu ul li.submenu:hover ul {
display: inline-block
}
<div id="menu">
<ul>
<li onClick="Dashboard();">Dashboard</li>
<li class="submenu">Employee >
<ul>
<li>Add Employee</li>
<li>Employee View</li>
</ul>
</li>
<li>Leave</li>
<li class="submenu">Salary
<ul>
<li>Add Employee</li>
<li>Employee View</li>
</ul>
</li>
<li>Change Password</li>
</ul>
</div>
Also Add .submenu class to submenu dropdown parent li.
I have a menu, and I would like to have the last 3 options (some images for Facebook/Twiter/Gmail) to be aligned to the right. So far I tried:
li:last-child { float:right;}- combine the 3 images in one to have the last option to the right, but not even so works
float: right; - the same result as above
text-align: right; - no change
#nav {
background-color: #e26a63;
padding: 0;
margin: 0;
font-family: FONT;
font-size: 20px;
}
#wrap {
padding-left: 60px;
height: 100px;
width: 100%;
margin: 0 auto;
display: table-cell;
vertical-align: bottom;
}
#nav ul {
list-style-type: none;
padding: 0;
margin: 0;
position: relative;
min-width: 225px;
}
#nav ul li {
display: inline-block;
}
#nav ul li:hover {
background-color: #cb5f59;
}
#nav ul li:after {
content: "";
font-size: 0;
display: block;
height: 5px;
}
#nav ul li:hover:after {
background: #9e4a45;
}
#nav ul ul li:hover:after {
background: transparent;
}
#nav ul li a, visited {
color: white;
display: block;
padding: 15px;
text-decoration: none;
}
#nav ul li:hover ul {
display: block;
}
#nav ul ul {
display: none;
position: absolute;
background-color: #e26a63;
border-top: 0;
margin-top: 5px;
z-index: 10;
}
#nav ul ul li {
display: block;
}
#nav ul ul li a:hover {
color: white;
}
<div id="nav">
<div id="wrap">
<ul>
<li>Home</li><li>
Study</li><li>
Games
<ul>
<li>Riddles</li><li>
Flip card game</li><li>
Spot the mistake</li><li>
Multiple choice</li>
</ul>
</li><li>
Read</li><li>
Contact</li><li>
About Us</li><li id="alignright">
FB
</li><li>
Twitter
</li><li style="text-align: right;">
Gmail
</li>
</ul>
</div>
</div>
Flexbox can do that:
JSfiddle Demo
#nav {
background-color: #e26a63;
padding: 0;
margin: 0;
font-family: FONT;
font-size: 20px;
}
#wrap {
height: 100px;
}
#nav ul {
list-style-type: none;
padding: 0;
margin: 0;
position: relative;
display: flex;
align-items: center;
}
#nav ul li {} #nav ul li:hover {
background-color: #cb5f59;
}
#nav ul li:after {
content: "";
font-size: 0;
display: block;
height: 5px;
}
#nav ul li:hover:after {
background: #9e4a45;
}
#nav ul ul li:hover:after {
background: transparent;
}
#nav ul li a {
color: white;
display: block;
padding: .5em;
text-decoration: none;
}
#nav ul li:hover ul {
display: block;
}
#nav ul ul {
display: none;
position: absolute;
background-color: #e26a63;
border-top: 0;
margin-top: 5px;
z-index: 10;
}
#nav ul ul li {
display: block;
}
#nav ul ul li a:hover {
color: white;
}
#alignright {
margin-left: auto;
}
<div id="nav">
<div id="wrap">
<ul>
<li>Home
</li>
<li>
Study
</li>
<li>
Games
<ul>
<li>Riddles
</li>
<li>
Flip card game
</li>
<li>
Spot the mistake
</li>
<li>
Multiple choice
</li>
</ul>
</li>
<li>
Read
</li>
<li>
Contact
</li>
<li>
About Us
</li>
<li id="alignright">
FB
</li>
<li>
Twitter
</li>
<li style="text-align: right;">
Gmail
</li>
</ul>
</div>
</div>
First of all:
#nav {
display: table;
width: 100%;
}
.alignright { float: right; }
i have a menu i'm developing at this link:
http://events.discoverportland.net/
The menu should load to a blue square just to the right of the discover portland logo. There are serveral nested ul's in the menu, the problem i'm having is getting them to load to the side of the menus above them As it load now, you can't get to the teritairy links unless you move VERY fast.
Is there any way to get the uls to load inline as i'm hovering over them, or is there a better solution?
this my nav html:
<nav>
<div class="clearfix hd8 suckerfish" >
<ul id="md">
<li>Home2</li>
<li>Neighborhoods
<ul>
<li>Northwest
<ul>
<li>Pearl District</li>
<li>Oldtown-Chinatown </li>
<li>Nob Hill</li>
</ul>
</li>
<li>Southwest
<ul>
<li>West End</li>
<li>Riverplace-South Waterfront</li>
<li>Downtown</li>
</ul>
</li>
<li>Southeast
<ul>
<li>Sellwood-Westmoreland</li>
<li>Hawthorne</li>
<li>Clinton-Division</li>
</ul>
</li>
<li>Northeast
<ul>
<li>Alberta</li>
<li>Lloyd District</li>
<li>Hollywood District</li>
</ul>
</li>
<li>North
<ul>
<li>Mississippi</li>
<li>Williams</li>
<li>St. Johns</li>
</ul>
</li>
</ul>
</li>
<li>Itineraries</li>
<li>Day Trips</li>
<li>Food+Drink
<ul>
<li>Dining Picks</li>
<li>Food Cart Fare </li>
<li>Beer, Wine & Spirits</li>
<li>Café Culture</li>
</ul>
</li>
<li>To Do
<ul>
<li>Shopping</li>
<li>Recreation</li>
<li>Culture
<ul>
<li>Galleries</li>
</ul>
</li>
<li>Family</li>
</ul>
</li>
<li>Events</li>
</ul>
</nav>
this is the css i'm using:
nav ul ul li a::before {
content: "\f0da";
font-family: FontAwesome;
margin-right: 8px;
}
nav {
text-transform:uppercase;
font-family: Oswald,Arial,Helvetica,sans-serif !important;
font-size: 14px;
font-weight: 100 !important;
letter-spacing: 1px!important;
}
nav ul ul {
display: none;
}
nav ul li:hover > ul {
display: block;
}
nav ul {
background: #FF0066;
padding: 2px 0 0 64px;
border-radius: 0px;
list-style: none;
position: relative;
display: inline-table;
}
nav ul:after {
content: ""; clear: both; display: block;
}
nav ul li {
float: left;
}
nav ul li:hover {
background: #FF0066;
}
nav ul li:hover a {
color: #fff;
}
nav ul li a {
display: block; padding: 15px 20px;
color: #fff; text-decoration: none;
}
nav ul ul {
background: #FF0066; border-radius: 0px; padding: 0;
position: absolute; top: 100%;
}
nav ul ul li {
float: none;
position: relative;
}
nav ul ul li a {
padding: 15px 25px;
color: #fff;
font-family: 'Fira Sans', sans-serif;Important;
font-size: 12px;
}
nav ul ul li a:hover {
background: #AD0548;
}
nav ul ul ul {
position: absolute; left: 100%; top:0;
}
nav ul ul ul li {
width: 275px !important;
}
#media (max-width: 767px) {
#logo a {
background: rgba(0, 0, 0, 0) url("http://discoverportland.net/templates/urbanlife/images/logos/DP_HeadingLogo2.png") no-repeat scroll 0 0 / 100% auto;
height: 60px;
margin: 0 !important;
width: 60px !important;
}
#menu-icon {
display:inline-block;
}
nav ul, nav:active ul {
display: none;
position: absolute;
right: 20px;
top: 60px;
width: 50%;
border-radius: 4px 0 4px 4px;
}
nav li {
text-align: center;
width: 100%;
padding: 10px 0;
margin: 0;
}
nav:hover #md {
display: inline-block;
}
}
I have noticed my nav bar is transparent and I would like it to not be. I have no previous opacity/transparency set that would cause it to be inheriting the property. I would like to make my nav bar non transparent.
Here is the CSS:
nav {
margin: 20px auto;
text-align: center;
}
nav ul ul {
display: none;
}
nav ul li:hover > ul {
display: block;
}
nav ul {
font-size: 25px;
background: white;
padding: 0px;
border-radius: 10px;
border-style: solid;
list-style: none;
position: relative;
display: inline-table;
}
nav ul:after {
content: "";
clear: both;
display: block;
}
nav ul li {
float: left;
}
nav ul li:hover {
background: black;
}
nav ul li:hover a {
opacity: 1;
color: white;
}
nav ul li a {
display: block;
padding: 15px 20px;
color: black;
text-decoration: none;
}
nav ul ul {
background: #000000;
border-radius: 0px 0px 10px 10px;
padding: 0;
position: absolute;
top: 100%;
}
nav ul ul li {
float: none;
}
nav ul ul li a {
padding: 15px 20px;
}
nav ul ul li a:hover {
background: #2E2E2E;
border-radius: 10px;
}
#welcome_paragraph {
position: relative;
top: 50px;
width: 500px;
margin: auto;
}
Here is the corresponding HTML:
<nav>
<ul>
<li>Information
<ul>
<li>Getting Started?</li>
<li>About Us</li>
<li>Contact</li>
</ul>
</li>
<li>Starter Kits</li>
<li>Rebuildables
<ul>
<li>Genesis</li>
<li>Dripper</li>
<li>Silica/Cotton</li>
</ul>
</li>
<li>Mods
<ul>
<li>Mechanical</li>
<li>Variable Voltage</li>
</ul>
</li>
<li>Accessories</li>
</ul>
</nav>
<p id="welcome_paragraph">
Welcome, blah blah (this text shows through the nav bar)<br />
</p>
HTML
<nav>
<ul>
<li>Information
<ul>
<li>Getting Started?
</li>
<li>About Us
</li>
<li>Contact
</li>
</ul>
</li>
<li>Starter Kits
</li>
<li>Rebuildables
<ul>
<li>Genesis
</li>
<li>Dripper
</li>
<li>Silica/Cotton
</li>
</ul>
</li>
<li>Mods
<ul>
<li>Mechanical
</li>
<li>Variable Voltage
</li>
</ul>
</li>
<li>Accessories
</li>
</ul>
</nav>
<p id="welcome_paragraph">Welcome, blah blah (this text shows through the nav bar)
<br />
</p>
CSS
nav {
margin: 20px auto;
text-align: center;
}
nav ul ul {
display: none;
}
nav ul li:hover > ul {
display: block;
}
nav ul {
font-size: 25px;
background: white;
padding: 0px;
border-radius: 10px;
border-style: solid;
list-style: none;
position: relative;
display: inline-table;
}
nav ul:after {
content: "";
clear: both;
display: block;
}
nav ul li {
float: left;
}
nav ul li:hover {
background: black;
position:relative;
z-index:1;
}
nav ul li:hover a {
color: white;
position:relative;
z-index:1;
}
nav ul li a {
display: block;
padding: 15px 20px;
color: black;
text-decoration: none;
}
nav ul ul {
background: #000000;
border-radius: 0px 0px 10px 10px;
padding: 0;
position: absolute;
top: 100%;
}
nav ul ul li {
float: none;
}
nav ul ul li a {
padding: 15px 20px;
}
nav ul ul li a:hover {
background: #2E2E2E;
border-radius: 10px;
}
#welcome_paragraph {
position: relative;
top: 50px;
width: 500px;
margin: auto;
color:white;
}
body
{
background-color:blue;
}
Updated CSS of yours
nav ul li:hover {
background: black;
position:relative;
z-index:1;
}
nav ul li:hover a {
color: white;
position:relative;
z-index:1;
}
Updated Fiddle
Have you tried;
nav {
background: white;
}
Elements are transparent unless you set a background on them or its inherited.
EDIT: If this doesn't help set up a fiddle for us jsfiddle.net.
In your css
nav ul {
font-size: 25px;
background: white;
padding: 0px;
border-radius: 10px;
border-style: solid;
list-style: none;
position: relative;
display: inline-table;
}
background is white.
If you change background to other colour may be your problem will go off. Hope it will help
Cheers !!