CSS drop-down menu not showing sub-menu on hover, but find out the actual problem. Below are the HTML and CSS. Please see fiddle.
It looks display: block; has no effect at all.
body {
background-color: #eee;
padding: 0;
}
.inline-menu,
.inline-menu ul {
list-style: none;
padding: 0;
margin: 0;
}
.inline-menu > li {
display: inline-block;
padding-right: 25px;
}
.inline-menu a {
text-decoration: none;
}
.inline-menu > li > ul {
display: none;
}
.inline-menu > li > ul:hover {
display: block;
}
<nav>
<span class="logo"></span>
<ul class="inline-menu left-menu">
<li>L-A
<ul>
<li>1
</li>
<li>2
</li>
</ul>
</li>
<li>L-B
<ul>
<li>1
</li>
<li>2
</li>
</ul>
</li>
</ul>
</nav>
You are applying hover to the wrong element- use this:
.inline-menu > li:hover > ul{
display: block;
}
instead of .inline-menu > li > ul:hover
body{
background-color: #eee;
padding: 0;
}
.inline-menu,
.inline-menu ul{
list-style: none;
padding: 0;
margin: 0;
}
.inline-menu > li{
display: inline-block;
padding-right: 25px;
}
.inline-menu a{
text-decoration: none;
}
.inline-menu > li > ul{
display: none;
}
.inline-menu > li:hover > ul{
display: block;
}
<nav>
<span class="logo"></span>
<ul class="inline-menu left-menu">
<li>L-A
<ul>
<li>1</li>
<li>2</li>
</ul>
</li>
<li>L-B
<ul>
<li>1</li>
<li>2</li>
</ul>
</li>
</ul>
</nav>
* {
margin: 0px;
padding: 0px;
}
#menu ul {
list-style: none;
}
#menu ul li {
float: left;
width: 150px;
height: 50px;
background-color: #0C3;
border: 1px solid #FFF;
text-align: center;
line-height: 50px;
position: relative;
}
#menu ul li a {
color: #CC0;
display: block;
text-decoration: none;
}
#menu ul li a:hover {
background: #C30;
color: #FFF;
}
#menu ul ul {
display: none;
position: absolute;
}
#menu ul li:hover> ul {
display: block;
}
<div id="menu">
<ul>
<li>L-A
<ul>
<li>A
</li>
<li>B
</li>
</ul>
</li>
<li>L-B
<ul>
<li>C
</li>
<li>D
</li>
</ul>
</li>
</li>
</div>
</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'm a beginner when it comes to html and css, I have to make a website as a school project. I want to add the search bar in the navbar using css, I'v been searching but I couldn't find the answer.
Here's my code:
jQuery(function($) {
$('#search-trigger').click(function() {
$('#search-input').toggleClass('search-input-open');
});
$(document).click(function(e) {
if (!$(e.target).closest('.ngen-search-form').length) {
$('#search-input').removeClass('search-input-open');
}
})
});
body {
padding: 0;
margin: 0;
overflow-y: scroll;
font-family: Arial;
font-size: 18px;
background-image: url("Background5.gif");
background-size: 1366px 800px;
background-repeat: no-repeat;
}
#header img {
max-width: 100%;
height: 100%;
}
#nav {
background-color: #222;
}
#nav_wrapper {
width: 960 px;
margin: 0 auto;
text-align: left;
}
#nav ul {
list-style-type: none;
padding: 0;
margin: 0;
position: relative;
}
#nav ul li {
display: inline-block;
}
#nav ul li:hover {
background-color: #333;
}
#nav ul li a,
visited {
color: #ccc;
display: block;
padding: 15px;
text-decoration: none;
}
#nav ul li a:hover {
color: #ccc;
text-decoration: none;
}
#nav ul li:hover ul {
display: block;
}
#nav ul ul {
display: none;
position: absolute;
background-color: #333;
border: 2px solid #222;
border-top: 0;
margin-left: -2px;
}
#nav ul ul li {
display: block;
}
#nav ul ul li a,
visited {
color: #ccc;
}
#nav ul li li a:hover {
color: #099;
}
#nav ul ul ul {
display: none;
position: absolute;
background-color: #333;
border: 2px solid #222;
border-top: 0;
margin-left: -2px;
}
#nav ul ul ul li {
display: block;
}
#nav ul ul ul li a,
visited {
color: #ccc;
}
#nav ul ul li li a:hover {
color: #099;
}
#nav ul ul ul ul {
display: none;
position: absolute;
background-color: #333;
border: 2px solid #222;
border-top: 0;
margin-left: -2px;
}
#nav ul ul ul ul li {
display: block;
}
#nav ul ul ul ul li a,
visited {
color: #ccc;
}
#nav ul ul ul li li a:hover {
color: #099;
}
#nav ul ul ul ul ul {
display: none;
position: absolute;
background-color: #333;
border: 2px solid #222;
border-top: 0;
margin-left: -2px;
}
#nav ul ul ul ul ul li {
display: block;
}
#nav ul ul ul ul ul li a,
visited {
color: #ccc;
}
#nav ul ul ul ul li li a:hover {
color: #099;
}
.form {
padding: 0px 0px 0px 0px;
float: right;
}
.form-search-input {
width: 0px;
height: 55px;
border: 0;
outline: 0;
font-size: 21px;
padding: 0px 0px 0px 0px;
color: #151515;
transition: all 0.5s;
}
.search-input-open {
width: 410px !important;
padding: 0px 0px 0px 20px !important;
display: initial !important;
}
.form-search-submit {
display: inline-block;
width: 55px;
height: 43px;
border: 0;
outline: 0;
background-color: #151515;
font-size: 21px;
color: #FFF;
cursor: pointer;
text-align: center;
}
<div id="maincontainer">
<div id="header">
<img src="C:\Users\Shogun\Desktop\The Witcher 3 Website\Banner.jpg" alt="the witcher 3 banner" id="thewitcherIMG" />
</div>
<div id="nav">
<div id="nav wrapper"></div>
<ul>
<li><a class="active" href="#">Home</a>
</li>
<li>
Story
<ul>
<li>Child of Prophecy
</li>
<li>
The Wild Hunt
</li>
<li>
Romance
</li>
<li>
Choice & Consequence
</li>
</ul>
</li>
<li>
Regions
<ul>
<li>White Orchard
</li>
<li>
Velen-No Man's Land
</li>
<li>
Novigrad
</li>
<li>
Royal Palace in Vizima
</li>
<li>
The Skellige Isles
</li>
<li>
Kaer Morhen
</li>
</ul>
</li>
<li>
Bestiary
<ul>
<li>Beasts
</li>
<li>
Cursed Ones
</li>
<li>
Draconians
</li>
<li>
Elementals
</li>
<li>
Hybrids
</li>
<li>
Insectoids
</li>
<li>
Necrophages
</li>
<li>
Ogroids
</li>
<li>
Relicts
</li>
<li>
Specters
</li>
<li>
Vampires
</li>
</ul>
</li>
<li>
Monster Hunts
</li>
<li>
DLC's
<ul>
<li>Heaarts of Stone
</li>
<li>
Blood and Wine
</li>
</ul>
</li>
<li>
CD Projekt Red
</li>
</ul>
<div>
<div class="form">
<form class="form-search ngen-search-form" action="" method="get">
<input type="text" name="q" id="search-input" class="form-search-input" placeholder="Search..." dir="ltr">
<span id="search-trigger" class="form-search-submit">🔎</span>
</form>
</div>
</div>
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
Try this:
jQuery(function($) {
$('#search-trigger').click(function() {
$('#search-input').toggleClass('search-input-open');
});
$(document).click(function(e) {
if (!$(e.target).closest('.ngen-search-form').length) {
$('#search-input').removeClass('search-input-open');
}
})
});
body {
padding: 0;
margin: 0;
overflow-y: scroll;
font-family: Arial;
font-size: 18px;
background-image: url("Background5.gif");
background-size: 1366px 800px;
background-repeat: no-repeat;
}
#header img {
max-width: 100%;
height: 100%;
}
#nav {
background-color: #222;
}
#nav_wrapper {
width: 960 px;
margin: 0 auto;
text-align: left;
}
#nav ul {
list-style-type: none;
padding: 0;
margin: 0;
position: relative;
}
#nav ul li {
display: inline-block;
}
#nav ul li:hover {
background-color: #333;
}
#nav ul li a,
visited {
color: #ccc;
display: block;
padding: 15px;
text-decoration: none;
}
#nav ul li a:hover {
color: #ccc;
text-decoration: none;
}
#nav ul li:hover ul {
display: block;
}
#nav ul ul {
display: none;
position: absolute;
background-color: #333;
border: 2px solid #222;
border-top: 0;
margin-left: -2px;
}
#nav ul ul li {
display: block;
}
#nav ul ul li a,
visited {
color: #ccc;
}
#nav ul li li a:hover {
color: #099;
}
#nav ul ul ul {
display: none;
position: absolute;
background-color: #333;
border: 2px solid #222;
border-top: 0;
margin-left: -2px;
}
#nav ul ul ul li {
display: block;
}
#nav ul ul ul li a,
visited {
color: #ccc;
}
#nav ul ul li li a:hover {
color: #099;
}
#nav ul ul ul ul {
display: none;
position: absolute;
background-color: #333;
border: 2px solid #222;
border-top: 0;
margin-left: -2px;
}
#nav ul ul ul ul li {
display: block;
}
#nav ul ul ul ul li a,
visited {
color: #ccc;
}
#nav ul ul ul li li a:hover {
color: #099;
}
#nav ul ul ul ul ul {
display: none;
position: absolute;
background-color: #333;
border: 2px solid #222;
border-top: 0;
margin-left: -2px;
}
#nav ul ul ul ul ul li {
display: block;
}
#nav ul ul ul ul ul li a,
visited {
color: #ccc;
}
#nav ul ul ul ul li li a:hover {
color: #099;
}
.form {
padding: 0px 0px 0px 0px;
float: right;
}
.form-search-input {
width: 0px;
height: 55px;
border: 0;
outline: 0;
font-size: 21px;
padding: 0px 0px 0px 0px;
color: #151515;
transition: all 0.5s;
}
.search-input-open {
width: 410px !important;
padding: 0px 0px 0px 20px !important;
display: initial !important;
}
.form-search-submit {
display: inline-block;
width: 55px;
height: 43px;
border: 0;
outline: 0;
background-color: #151515;
font-size: 21px;
color: #FFF;
cursor: pointer;
text-align: center;
}
<div id="maincontainer">
<div id="header">
<img src="C:\Users\Shogun\Desktop\The Witcher 3 Website\Banner.jpg" alt="the witcher 3 banner" id="thewitcherIMG" />
</div>
<div id="nav">
<div id="nav wrapper"></div>
<ul>
<li><a class="active" href="#">Home</a>
</li>
<li>
Story
<ul>
<li>Child of Prophecy
</li>
<li>
The Wild Hunt
</li>
<li>
Romance
</li>
<li>
Choice & Consequence
</li>
</ul>
</li>
<li>
Regions
<ul>
<li>White Orchard
</li>
<li>
Velen-No Man's Land
</li>
<li>
Novigrad
</li>
<li>
Royal Palace in Vizima
</li>
<li>
The Skellige Isles
</li>
<li>
Kaer Morhen
</li>
</ul>
</li>
<li>
Bestiary
<ul>
<li>Beasts
</li>
<li>
Cursed Ones
</li>
<li>
Draconians
</li>
<li>
Elementals
</li>
<li>
Hybrids
</li>
<li>
Insectoids
</li>
<li>
Necrophages
</li>
<li>
Ogroids
</li>
<li>
Relicts
</li>
<li>
Specters
</li>
<li>
Vampires
</li>
</ul>
</li>
<li>
Monster Hunts
</li>
<li>
DLC's
<ul>
<li>Heaarts of Stone
</li>
<li>
Blood and Wine
</li>
</ul>
</li>
<li>
CD Projekt Red
</li>
<li>
<div class="form">
<form class="form-search ngen-search-form" action="" method="get">
<input type="text" name="q" id="search-input" class="form-search-input" placeholder="Search..." dir="ltr">
<span id="search-trigger" class="form-search-submit">🔎</span>
</form>
</div>
</li>
</ul>
<div>
</div>
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
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>
I guess the answer is simple, but still, I cannot figure out how to make my second level menu viewed as an inline-block - from this:
to this:
So what I need is an inline block-listing + text aligned to the center.
Thank you very much for your help.
HTML:
<ul id="menu">
<li>Home</li>
<li>About Us
<ul>
<li>The Team</li>
<li>History</li>
<li>Vision</li>
</ul>
</li>
<li>Products
<ul>
<li>Cozy Couch</li>
<li>Great Table</li>
<li>Small Chair</li>
<li>Shiny Shelf</li>
<li>Invisible Nothing</li>
</ul>
</li>
<li>Contact
<ul>
<li>Online</li>
<li>Right Here</li>
<li>Somewhere Else</li>
</ul>
</li>
CSS:
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: #1e7c9a;
margin-left:1px;
white-space: nowrap;
}
ul li a:hover {
background: #BBBBBB;
}
li:hover ul {
display: block;
position: absolute;
}
li:hover li {
float: none;
font-size: 11px;
}
li:hover a {
background: #3b3b3b;
}
li:hover li a:hover {
background: #CCC;
}
add this to your css
ul li {
display: block;
float: left;
}
li:hover ul {
display: block;
position: absolute;
left:0px;
}
li:hover li {
float: left;
font-size: 11px;
}
Demo