I want move objects to the right but don't know how!? Any idea?
. Please help me. Here is the code in HTML and CSS
/*=====================================
= Top Bar
=====================================*/
#top-bar {
height: 42px;
line-height: 40px;
background: #f9f9f9;
color: #888;
font-size: .857em;
border-bottom: 1px solid #f5f5f5;
}
.top-nav ul li {
display: block;
float: left;
}
.top-nav ul {
margin: 0;
padding: 0;
}
.top-nav {
font-family: "Montserrat",Open Sans,Sans-serif;
}
.top-nav ul li a {
color: #111;
text-decoration: none;
display: inline-block;
padding: 0 15px;
line-height: .917em;
color: #888;
text-decoration: none;
text-transform: uppercase;
letter-spacing: .5px;
font-size: .917em;
border-right: 1px solid #eee;
}
.top-notification {
float: right;
}
.top-notification p {
margin: 0;
float: left;
font-size: 13px;
}
.top-notification a {
color: #111;
text-decoration: none;
/* display: inline-block; */
padding: 5px 9px;
line-height: .917em;
color: #888;
text-decoration: none;
text-transform: uppercase;
letter-spacing: .5px;
font-size: .917em;
border: 1px solid #D1D1D1;
margin-left: 22px;
background:#fff;
}
nav ul {
padding: 0;
margin: 0;
list-style: none;
position: relative;
}
nav ul li {
display:inline-block;
}
nav ul li a:link {
display: inline-block;
padding: 15px 25px;
text-transform: uppercase;
letter-spacing: 1px;
position: relative;
text-decoration: none!important;
color: #fff;
width:100%;
}
nav ul li a {
color: #fff!important;
}
nav a:hover {
background-color: #2da399;
}
/* Hide Dropdowns by Default */
nav ul ul {
display: none;
position: absolute;
z-index: 1000;
background: #494949;
}
/* Display Dropdowns on Hover */
nav ul li:hover > ul {
display:inherit;
}
/* Fisrt Tier Dropdown */
nav ul ul li {
min-width:170px;
float:none;
display:list-item;
position: relative;
}
nav ul ul a:hover {
background-color: #656565;
}
/* Change this in order to change the Dropdown symbol */
nav li > a:after { content: ' +'; }
nav li > a:only-child:after { content: ''; }
.menu {
width: 1200px;
margin: auto;
z-index: 99999;
background: #2da399;
}
.menu.cloned {
width: 100%!important;
left: 0!important;
}
.menu.cloned nav {
width: 1200px;
margin: auto;
}
Here is HTML codes for my website. I think every thing in is fine here and the problem is in CSS codes.
<!--Main Navigation-->
<div class='menu-wrapper'>
<div class='menu'>
<nav>
<ul>
<li><a href='https://thevoiceofafghanistan.blogspot.se/p/kontakta-mig.html'>Hem</a></li>
<li><a href='#'>Nyheter </a>
<!-- First Tier Drop Down -->
<ul>
<li><a href='https://thevoiceofafghanistan.blogspot.se/p/afghanistan.html'>Afghanistan</a></li>
<li><a href='https://thevoiceofafghanistan.blogspot.se/p/sverige-och-e.html'>Sverige</a></li>
<li><a href='#'>Världen</a></li>
</ul>
</li>
<li><a href='#'>Vetenskap
</a>
<!-- First Tier Drop Down -->
<ul>
<li><a href='https://www.facebook.com/thevoiceofafghanistan/'>Kemi
</a></li>
<li><a href='#'>Fysik </a></li>
<li><a href='#'>Matte</a>
<!-- Second Tier Drop Down -->
<ul>
<li><a href=''>Matte 1</a></li>
<li><a href='#'>Matte 2</a></li>
<li><a href='#'>Matte 3</a>
<!-- Third Tier Drop Down -->
<ul>
<li><a href='#'>Matte 4</a></li>
<li><a href='#'>Hjälpmedel
</a></li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
<li><a href='#'>فناوری </a></li>
<li><a href='#'>اجتمائی </a></li>
<li><a href='#'> سیاست</a></li>
<li><a href='#'>تاریخ </a></li>
<li><a href=''>کلاس ها</a></li>
<li><a href='https://thevoiceofafghanistan.blogspot.se/'>صفحه اصلی </a></li>
</ul>
</nav>
</div>
</div>
This is menu bar
You should add some margin-left to your css. As you have not provided your full HTML I cannot say which attribute exactly needs the stylling.
I think you should add margin-left to your menus to increase space between them or to the parent div for shifting the whole navbar to the right. Hope this helps!
I'm going to assume that when you ask how to move them to the right that the ultimate goal is to center the navigation elements inside the blue-green field that is <nav>.
You might also be asking to align the navigation items to the right side of the blue-green field, I've addressed that in my second code snippet.
Center Nav Items
A common way to center something is to move it to the left by 50% and then pull it back 50% of it's width with transform. In order for this to work you'll need to make your <ul> not take up 100% of its parent element. You can do this a number of ways, for simplicity I have set it to display: inline-block;.
This solution will allow you to add/remove <li> and still be centered in <nav>.
nav ul {
display: inline-block;
position: relative;
left: 50%;
padding: 0;
margin: 0;
transform: translateX( -50%);
list-style: none;
}
nav ul li {
display: inline-block;
}
nav ul li a:link {
display: inline-block;
padding: 15px 25px;
text-transform: uppercase;
letter-spacing: 1px;
position: relative;
text-decoration: none !important;
color: #fff;
}
nav ul li a {
color: #fff !important;
}
nav a:hover {
background-color: #2da399;
}
/* Hide Dropdowns by Default */
nav ul ul {
display: none;
position: absolute;
z-index: 1000;
background: #494949;
}
/* Display Dropdowns on Hover */
nav ul li:hover>ul {
display: inherit;
}
/* Fisrt Tier Dropdown */
nav ul ul li {
min-width: 170px;
float: none;
display: list-item;
position: relative;
}
nav ul ul a:hover {
background-color: #656565;
}
/* Change this in order to change the Dropdown symbol */
nav li>a:after {
content: ' +';
}
nav li>a:only-child:after {
content: '';
}
.menu {
width: 1200px;
margin: auto;
z-index: 99999;
background: #2da399;
}
<!--Main Navigation-->
<div class='menu-wrapper'>
<div class='menu'>
<nav>
<ul>
<li><a href='https://thevoiceofafghanistan.blogspot.se/p/kontakta-mig.html'>Hem</a></li>
<li><a href='#'>Nyheter </a>
<!-- First Tier Drop Down -->
<ul>
<li><a href='https://thevoiceofafghanistan.blogspot.se/p/afghanistan.html'>Afghanistan</a></li>
<li><a href='https://thevoiceofafghanistan.blogspot.se/p/sverige-och-e.html'>Sverige</a></li>
<li><a href='#'>Världen</a></li>
</ul>
</li>
<li><a href='#'>Vetenskap
</a>
<!-- First Tier Drop Down -->
<ul>
<li><a href='https://www.facebook.com/thevoiceofafghanistan/'>Kemi
</a></li>
<li><a href='#'>Fysik </a></li>
<li><a href='#'>Matte</a>
<!-- Second Tier Drop Down -->
<ul>
<li><a href=''>Matte 1</a></li>
<li><a href='#'>Matte 2</a></li>
<li><a href='#'>Matte 3</a>
<!-- Third Tier Drop Down -->
<ul>
<li><a href='#'>Matte 4</a></li>
<li><a href='#'>Hjälpmedel
</a></li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
<li><a href='#'>فناوری </a></li>
<li><a href='#'>اجتمائی </a></li>
<li><a href='#'> سیاست</a></li>
<li><a href='#'>تاریخ </a></li>
<li><a href=''>کلاس ها</a></li>
<li><a href='https://thevoiceofafghanistan.blogspot.se/'>صفحه اصلی </a></li>
</ul>
</nav>
</div>
</div>
I noticed you included a little more CSS than what was being used by your markup so I removed it.
Align Nav Items to Right
If you are looking to align the navigation to the right side instead of the left side you can float the <ul> to the right. The only catch here is that you will need to clear the float so you can see the background color of .menu. I used the poor man's clearfix, overflow: hidden; but you could use the more modern option of the Micro Clearfix.
nav ul {
float: right;
display: inline;
position: relative;
padding: 0;
margin: 0;
list-style: none;
}
nav ul li {
display: inline-block;
}
nav ul li a:link {
display: inline-block;
padding: 15px 25px;
text-transform: uppercase;
letter-spacing: 1px;
position: relative;
text-decoration: none !important;
color: #fff;
}
nav ul li a {
color: #fff !important;
}
nav a:hover {
background-color: #2da399;
}
/* Hide Dropdowns by Default */
nav ul ul {
display: none;
position: absolute;
z-index: 1000;
background: #494949;
}
/* Display Dropdowns on Hover */
nav ul li:hover>ul {
display: inherit;
}
/* Fisrt Tier Dropdown */
nav ul ul li {
min-width: 170px;
float: none;
display: list-item;
position: relative;
}
nav ul ul a:hover {
background-color: #656565;
}
/* Change this in order to change the Dropdown symbol */
nav li>a:after {
content: ' +';
}
nav li>a:only-child:after {
content: '';
}
.menu {
width: 1200px;
margin: auto;
z-index: 99999;
background: #2da399;
overflow: hidden; /* Clearfix that allows the background of <nav> to be seen with floated child elements. */
}
<!--Main Navigation-->
<div class='menu-wrapper'>
<div class='menu'>
<nav>
<ul>
<li><a href='https://thevoiceofafghanistan.blogspot.se/p/kontakta-mig.html'>Hem</a></li>
<li><a href='#'>Nyheter </a>
<!-- First Tier Drop Down -->
<ul>
<li><a href='https://thevoiceofafghanistan.blogspot.se/p/afghanistan.html'>Afghanistan</a></li>
<li><a href='https://thevoiceofafghanistan.blogspot.se/p/sverige-och-e.html'>Sverige</a></li>
<li><a href='#'>Världen</a></li>
</ul>
</li>
<li><a href='#'>Vetenskap
</a>
<!-- First Tier Drop Down -->
<ul>
<li><a href='https://www.facebook.com/thevoiceofafghanistan/'>Kemi
</a></li>
<li><a href='#'>Fysik </a></li>
<li><a href='#'>Matte</a>
<!-- Second Tier Drop Down -->
<ul>
<li><a href=''>Matte 1</a></li>
<li><a href='#'>Matte 2</a></li>
<li><a href='#'>Matte 3</a>
<!-- Third Tier Drop Down -->
<ul>
<li><a href='#'>Matte 4</a></li>
<li><a href='#'>Hjälpmedel
</a></li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
<li><a href='#'>فناوری </a></li>
<li><a href='#'>اجتمائی </a></li>
<li><a href='#'> سیاست</a></li>
<li><a href='#'>تاریخ </a></li>
<li><a href=''>کلاس ها</a></li>
<li><a href='https://thevoiceofafghanistan.blogspot.se/'>صفحه اصلی </a></li>
</ul>
</nav>
</div>
</div>
Just set your nav ul li width to 100/number of items. and it will spread your menu items equally across the bar, removing the gap on the right as much as possible.
You can remove the space between inline block elements as you like by setting margin-right property accordingly.
Replace old nav ul li with this code:
nav ul li {
display:inline-block;
background-color: #2da399;
width:11%;
margin-right: -4px;
}
Doing the menu this way will allow your menu to wrap into various screen widths fully.
Related
I have a series of nested ul and li elements, to create a sidebar nav system. When the user hovers over one of the li elements I want the entire width of the background to change (shown right), not just the inside of the container (shown left).
The problem I'm having is that in order to make the entire width change, I need to remove the ul padding-left which then removes the indentation and 'nested' look of the list elements.
An example below shows the behaviour currently present, where the background-color does not change for the entire width. Preferably I wouldn't have to manually add in indentation for each element, as the nested padding works quite nicely as is, but am open to suggestions :D
* {
box-sizing: border-box;
}
nav {
width: 100px;
background-color: lightgrey;
}
li {
list-style: none;
}
ul {
padding-left: 10px;
}
a {
color: black;
text-decoration: none;
padding: 5px;
display: inline-block;
width: 100%;
}
a:hover {
background-color: grey;
color: white;
}
<nav>
<ul>
<li><a href='#'>Home</a></li>
<li><a href='#'>Work</a></li>
<ul>
<li><a href='#'>Piece 1</a></li>
<li><a href='#'>Piece 2</a></li>
</ul>
<li><a href='#'>Contact</a></li>
</ul>
</nav>
My questions:
How can I make the background of the entire width of the li update on hover, without removing the indentation for the nested list items.
Why are the width: 100% li elements not overflowing outside the nav bar? Since I thought width: 100% meant their width was the same as their parent's widths, which surely as they are indented would mean they would extend beyond.
Thanks!
Post Answer Edit
The accepted answer is definitely good, but the solution i ended up with was dynamically generating the navbar elements with JavaScript according to an object.
This solution works for any number of nested levels.
The trick is using CSS counter to pad levels.
* {
box-sizing: border-box;
}
nav {
display: inline-block;
background-color: lightgrey;
}
ul,
li {
margin: 0;
padding: 0;
list-style: none;
}
li {
counter-increment: section;
counter-reset: section;
}
a:before {
content: counters(section, '');
opacity: 0
}
a {
color: black;
text-decoration: none;
padding: 5px;
display: block;
}
a:hover {
background-color: grey;
color: white;
}
<nav>
<ul>
<li><a href='#'>Home</a></li>
<li><a href='#'>Work</a>
<ul>
<li><a href='#'>Piece 1</a></li>
<li><a href='#'>Piece 2</a>
<ul>
<li><a href='#'>Piece 2.1</a></li>
<li><a href='#'>Piece 2.2</a></li>
</ul>
</li>
</ul>
</li>
<li><a href='#'>Contact</a></li>
</ul>
</nav>
If you want the links to be the width of the list, you can remove the padding of the unordered list (ul). Put the padding on the links instead:
* {
box-sizing: border-box;
}
nav {
width: 100px;
background-color: lightgrey;
}
li {
list-style: none;
width: 100%;
}
ul {
padding-left: 0;
}
a {
color: black;
text-decoration: none;
box-sizing: border-box;
padding: 5px;
width: 100%;
padding-left: 15px;
display: inline-block;
width: 100%;
}
ul ul li a{
padding-left: 25px;
}
a:hover {
background-color: grey;
color: white;
}
<nav>
<ul>
<li><a href='#'>Home</a></li>
<li><a href='#'>Work</a></li>
<ul>
<li><a href='#'>Piece 1</a></li>
<li><a href='#'>Piece 2</a></li>
</ul>
<li><a href='#'>Contact</a></li>
</ul>
</nav>
I don't know how to really explain this in a simple question for the title, but I have an example page to show you what I mean at http://www.yenrac.net/test
I am having problems with dropdown menus, as you can see. Whenever I hover over to the next category in the dropdown 'accordion' it jumps back and screws with desktop cursors if they have their browser in a small window. Another thing is that mobile users cannot just click the box link again to close the dropdown, which is something else I would like to fix. Can someone please take a look at this and help me figure out what I am doing wrong?
Here is my HTML: http://pastebin.com/RkFs97wH
<nav>
<ul id="navigation">
<li><a id="current" href="index.html">Home</a></li>
<li>FAQ</li>
<li><a class="dropdown" href="#">Dropdown</a>
<ul>
<li>
<a class="pullout" href="#">Pullout Tab</a>
<ul>
<li>Tier 3 Tab</li>
</ul>
</li>
<li>
<a class="pullout" href="#">Pullout Tab 2</a>
<ul>
<li>Tier 3 Tab</li>
</ul>
</li>
</ul>
</li>
<li>Servers</li>
<li id="last">Contact Us</li>
</ul>
</nav>
Here is my CSS: http://pastebin.com/ttYh0Qz6
/* Set to very large range just for convenience of testing */
#media screen and (max-width: 10000px) {
#postdatemeta {
visibility: visible;
}
.postdate {
visibility: hidden;
}
nav ul {
list-style-type: none;
margin: 0 auto;;
padding: 0;
width: 98%;
}
nav li a {
display: block;
color: #fff;
padding: 1em 0;
margin: 0.3em auto;;
text-decoration: none;
text-align: center;
background: #000;
}
nav ul ul {
position: absolute;
visibility:hidden;
}
nav ul li:hover > ul {
visibility: visible;
position: relative;
}
nav ul ul li a {
background: #999;
}
.pullout:after {
content: "\000020\0025BE";
}
I appreciate any help and feedback you are able to provide me!
You are adding a margin to the a element, but the parent li item ignores these margins currently, so when you mouse over the margins, it recognizes you as moving the mouse off of the li, so the :hover state goes away resulting in a collapsed menu.
Try add the following:
nav li {
width: 100%;
display: inline-block;
}
This allows the li element to wrap the a element including the margins, so when they are moused over, the :hover state remains.
#media screen and (max-width: 10000px) {
nav ul {
list-style-type: none;
margin: 0 auto;
;
padding: 0;
width: 98%;
}
nav li {
width: 100%;
display: inline-block;
}
nav li a {
display: block;
color: #fff;
padding: 1em 0;
margin: 0.3em auto;
;
text-decoration: none;
text-align: center;
background: #000;
}
nav ul ul {
position: absolute;
visibility: hidden;
}
nav ul li:hover > ul {
visibility: visible;
position: relative;
}
nav ul ul li a {
background: #999;
}
.pullout:after {
content: "\000020\0025BE";
}
}
<nav>
<ul id="navigation">
<li><a id="current" href="index.html">Home</a>
</li>
<li>FAQ
</li>
<li><a class="dropdown" href="#">Dropdown</a>
<ul>
<li>
<a class="pullout" href="#">Pullout Tab</a>
<ul>
<li>Tier 3 Tab
</li>
</ul>
</li>
<li>
<a class="pullout" href="#">Pullout Tab 2</a>
<ul>
<li>Tier 3 Tab
</li>
</ul>
</li>
</ul>
</li>
<li>Servers
</li>
<li id="last">Contact Us
</li>
</ul>
</nav>
Please see this jsfiddle demo here. When I hover over sub1, the sub-sub-menu covers sub2. How do I make the sub-sub-menu appear on the right to the sub-menu but adjacent to sub1 (or sub2, as applicable)?
ul.topbar {
padding:0;
list-style: none;
background: #f2f2f2;
}
ul.topbar li {
display: inline-block;
position: relative;
line-height: 5vh;
text-align: left;
}
ul.topbar li a {
display: block;
padding: 8px 25px;
color: #333;
text-decoration: none;
white-space: nowrap;
}
ul.topbar li a:hover {
color: #fff;
background: #939393;
white-space: nowrap;
}
ul.topbar li ul.dropdown {
background: #f2f2f2;
display: none;
position: absolute;
z-index: 999;
left: 0;
}
ul.topbar li:hover ul.dropdown {
display: block; /* Display the dropdown */
}
ul.topbar li ul.dropdown li {
display: block;
}
ul.topbar li ul.dropdown {
padding:0;
list-style: none;
background: #f2f2f2;
}
ul.topbar li ul.dropdown li {
display: inline-block;
position: relative;
line-height: 5vh;
text-align: left;
}
ul.topbar li ul.dropdown li a {
display: block;
padding: 8px 25px;
color: #333;
text-decoration: none;
}
ul.topbar li ul.dropdown li a:hover {
color: #fff;
background: #939393;
}
ul.topbar li ul.dropdown li ul.dropdown {
min-width: 100px; /* Set width of the dropdown */
background: #f2f2f2;
display: none;
position: absolute;
z-index: 999;
left: 0;
}
ul.topbar li ul.dropdown li:hover ul.dropdown {
display: block; /* Display the dropdown */
position:absolute;
}
ul.topbar li ul.dropdown li ul.dropdown li {
display: block;
}
<ul class="topbar">
<li>top1</li>
<li>top2</li>
<li> <a href="#" > top3 ▾</a>
<ul class="dropdown">
<li> <a href="#" > sub1 ▸ </a>
<ul class="dropdown">
<li> <a href="#" >asfg </a></li>
<li> <a href="#" >hbch </a></li>
<li> <a href="#" >erft </a></li>
<li> <a href="#" >erft </a></li>
<li> <a href="#" >erft </a></li>
</ul>
</li>
<li> <a href="#" >sub2 ▸ </a>
<ul class="dropdown">
<li> <a href="#" >rtiuji </a></li>
<li> <a href="#" >erft </a></li>
<li> <a href="#" >erft </a></li>
<li> <a href="#" >erft </a></li>
<li> <a href="#" >erft </a></li>
</ul>
</li>
</ul>
</li>
<li>top5 ▾
<ul class="dropdown">
<li>Phy</li>
<li>Chem</li>
</ul>
</li>
<li>top6</li>
</ul>
In your CSS rule ul.topbar li ul.dropdown li ul.dropdown you want to fix the positioning.
You're already using position: absolute, that means this element will be positioned an absolute distance from the top left corner of it's closest ancestor with positioning set.
You then set left:0. That means make the left side be 0 pixels from the left side of it's ancestor. If you switch that to something like 100% (% positioning is based off the size of the ancestor not the element itself) you would now have pushed the menu over from the left by the full size of the ancestor - i.e. it will have it's left side aligned with the right side of the ancestor.
In your specific case you'll probably also want to add a top:0. Otherwise the element will keep it's original top position below the ancestor and be almost impossible to get your mouse over.
Also you might want to consider simplifying your rules. Take advantage of how CSS rules cascade so you don't have to make a unique rule for every level of your menu.
i am trying to create a nav bar for my website. the drop down is giving me trouble. how do i align the submenu so that it shows as a proper drop down?
<div id="mainhead">
<div id="title">
<h1>StudiousEnough </h1>
</div>
<li>Home</li>
<li><a href="" >class</a>
<ul>
<li> Class XI </li>
<li> CLass XII </li>
</ul>
</li>
<li><a href="#" >jee</a></li>
<li><a href="aboutus.html" >about us</a></li>
</ul>
and here is the css:
#mainhead #mainnav ul {
list-style-type: none;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
margin-left: 0px;
padding-top: 0px;
padding-right: 0px;
padding-bottom: 0px;
padding-left: 0px;
}
#mainhead #mainnav li {
display: block;
width: 25%;
background-color: #4D4D4D;
color: #FFFFFF;
text-align: center;
text-transform: uppercase;
float: left;
padding-bottom: 4px;
padding-top: 4px;
font-family: averia-libre;
font-style: normal;
font-weight: 700;
}
#mainhead #mainnav {
position: absolute;
width: 100%;
left: 0%;
right: 0%;
}
#mainhead #mainnav a{
display:block;
color: #ffffff;
text-decoration: none;
}
#mainhead #mainnav li:hover,#mainhead #mainnav li:focus,#mainhead #mainnav li:active {
background-color: #2535F3;
text-decoration: none;
}
#mainhead #mainnav ul li ul{
display: none;
}
#mainhead #mainnav ul li:hover ul{
display:block;
}
See the fiddle
I've added the following CSS to your CSS
CSS
#mainhead #mainnav ul li ul li{
width:100%;
clear:both;
}
First things first - check your html; you have some problems here. The list item tags need to be enclosed inside the unordered list parent tags. Also I don't see some of the ids and classes existing in the html that is used in your css.
If you always format your code, indenting enclosed blocks, that will help you spot all errors more quickly.
I went ahead and added a parent div with id = 'mainnav' and cleaned up your HTML, and it mostly renders as you'd expect. To get the submenu list items to 'stack' just make width 100%.
Clear is not necessary.
Check out the example on jsfiddle here:
https://jsfiddle.net/pianopaul/r3bb8k24/5/
<div id="mainhead">
<div id="title">
<h1>StudiousEnough </h1>
<div id="mainnav">
<ul class="menu">
<li>Home</li>
<li><a href="" >class</a>
<ul class="submenu">
<li> Class XI </li>
<li> CLass XII </li>
</ul>
</li>
<li><a href="#" >jee</a></li>
<li><a href="aboutus.html" >about us</a></li>
</ul>
</div>
</div>
</div>
I'm building a dropdown menu and I've got an issue showed on this img:
I want the "2.1" text to be displayed next to the "Item" text. For some reaason, every new word gets a new line.
Here's the html:
<ul id='nav'>
<li><a href='/'>Item 1</a></li>
<li><a href='/'>Item 2</a>
<ul>
<li><a href='/'>Item 2.1</a></li>
</ul>
</li>
<li><a href='/'>Item 3</a></li>
<li><a href='/'>Item 4</a></li>
<li><a href='/'>Item 5</a></li>
</ul>
And here's the CSS:
#nav {
list-style: none;
}
#nav li {
float: left;
position: relative;
}
#nav li a {
display: block;
text-decoration: none;
text-align: center;
background: #ccc;
margin-right: 5px;
}
#nav li ul {
position: absolute;
}
#nav li ul li {
display: block;
}
#nav li ul li a {
padding: 0px 10px;
height: 20px;
text-align: left;
background: #999;
}
Thanks for any help, Mike.
An easy way to fix this is adding a nowrap property to #nav li ul li a:
#nav li ul li a {
padding: 0px 10px;
height: 20px;
text-align: left;
background: #999;
white-space: nowrap; /* Forbids text wrapping */
}