how can I make a full width dropdown responsive menu - html

I am somehow not been able to manage this menu to full width
this is my codepen
http://codepen.io/anon/pen/xwDcb
i want my dropdown menu width to be 100% from left to right. What am I doing wrong
body {
background-color:#000;
}
.toggleMenu {
display: none;
background: #666;
padding: 10px 15px;
color: #fff;
text-transform: uppercase;
font-weight: bold;
width:100%;
}
.nav-full {
background:url(../images/nav-bg.png) no-repeat 0 0;
}
.nav-centre {
width:960px;
margin:0 auto
}
.nav {
list-style: none;
*zoom: 1;
}
.nav:before, .nav:after {
content:" ";
display: table;
}
.nav:after {
clear: both
}
.nav ul {
list-style: none;
}
my html code
<a class="toggleMenu" href="#">Menu</a>
<div class="nav-full">
<div class="nav-centre">
<ul class="nav">
<li>HOME
<ul>
<li>Indus Advantage
</li>
<li>Positioning and flexibility of products
</li>
<li>Pipeline
</li>
</ul>
</li>
<li> Products
<ul>
<li>Overview
</li>
<li>Exercise Physiology
</li>
<li>Manufacturing & Quality Control
</li>
</ul>
</li>
<li> Patents & Publications
<ul>
<li>Global Patenting Strategy
</li>
<li>Publications
</li>
</ul>
</li>
<li> Partnering
<ul>
<li>Enquiries - Product
</li>
<li>Enquiries - Business Partnering
</li>
</ul>
</li>
<li> About Us
<ul>
<li>Vision & Values
</li>
<li>Conventional v/s the Indus Discovery Model
</li>
</ul>
</li>
<li> Contact Us
</li>
<li> Careers
</li>
</ul>
</div>
</div>

check with this code
<style>
#nav {
height: 1;
list-style-type: none;
padding-top: 1.25em;
margin-top: 0em;
}
#nav > li { /* Added ">" */
float: right;
position: relative;
padding: 0;
}
#nav li a {
display: inline-block; /* was block */
font-size: 14px;
padding: 0 1em;
margin-bottom: 1em;
color: #333;
text-decoration: none;
border-left: 1px solid #333;
}
#nav .last, #nav li ul li a {
border-left: none;
}
#nav li a:hover, #nav li a:focus {
color: #666;
}
#nav li ul {
opacity: 0;
/*position: absolute;
right: 0em; */
list-style-type: none;
padding: 0; margin: 0;
}
#nav li:hover ul {
opacity: 1;
}
#nav li ul li {
/*float: none;
position: static;
width: auto;*/
height: 0;
line-height: 0;
background: none;
text-align: left;
margin-bottom: .75em;
}
#nav li:hover ul li {
height: 25px;
line-height: 2.5em;
}</style>
<ul id="nav">
<a class="toggleMenu" href="#">Menu</a>
<div class="nav-full">
<div class="nav-centre">
<ul class="nav">
<li>HOME
<ul>
<li>Indus Advantage
</li>
<li>Positioning and flexibility of products
</li>
<li>Pipeline
</li>
</ul>
</li>
<li> Products
<ul>
<li>Overview
</li>
<li>Exercise Physiology
</li>
<li>Manufacturing & Quality Control
</li>
</ul>
</li>
<li> Patents & Publications
<ul>
<li>Global Patenting Strategy
</li>
<li>Publications
</li>
</ul>
</li>
<li> Partnering
<ul>
<li>Enquiries - Product
</li>
<li>Enquiries - Business Partnering
</li>
</ul>
</li>
<li> About Us
<ul>
<li>Vision & Values
</li>
<li>Conventional v/s the Indus Discovery Model
</li>
</ul>
</li>
<li> Contact Us
</li>
<li> Careers
</li>
</ul>
</ul>
</div>
</div>

you have to give the nav-center class 100%, now its at 975px or something like that, and it wrapps your list elements. so the 100% of the unordered list are relative to the nav-center element.
and if you want to get the nav menu centered giv the nav-centre class position:relative;
left: 50% and margin:left -511px. (margin-left should be have of the width of the unordered list)
i think the best solution would be that you put the dropdown menu out of the ul from the navi.
So its not relative to the other list.
markup your html like this:
<a class="toggleMenu" href="#">Menu</a>
<div class="nav-full">
<div class="nav-centre">
<ul class="nav">
<li>HOME</li>
<li> Products</li>
<li> Patents & Publications</li>
<li> Partnering</li>
<li> About Us</li>
<li> Contact Us</li>
<li> Careers </li>
</ul>
<ul>
<li class="under">Indus Advantage</li>
<li class="under">Positioning and flexibility of products</li>
<li class="under">Pipeline
</ul>
<ul>
<li class="under">Overview</li>
<li class="under">Exercise Physiology</li>
<li class="under">Manufacturing & Quality Control</li>
</ul>
<ul>
<li class="under">Global Patenting Strategy</li>
<li class="under">Publications</li>
</ul>
<ul>
<li class="under">Enquiries - Product</li>
<li class="under">Enquiries - Business Partnering</li>
</ul>
<ul>
<li class="under">Vision & Values</li>
<li class="under">Conventional v/s the Indus Discovery Model</li>
</ul>
</div>
</div>
you now just have to give li.under position:absolute and the rest, how to style, should be clear.

Related

How can I stop my menu from expanding when I display subitems as a flyout?

I am totally new to CSS and trying to take some HTML code, and style it into a mix between a dropdown and flyout menu. I have been successful so far in completing most of my goals, however there is still one big problem I am running into.
The container is expanding to match the flyout menu that is displayed, even though it should be a separate menu.
I am assuming I either need to rework my whole design, or there is a small simple thing I am missing. Is there a way to stop the parent containers from expanding just because a child is displayed?
Here is what the HTML code looks like:
<nav>
<ul class="top-level">
<li>
<span>Services</span>
<ul class="drop-down">
<li>
<span>Website Development</span>
<ul class="fly-out">
<li>
<span>Responsive Website Design</span>
</li>
<li>
<span>E-Commerce</span>
</li>
<li>
<span>DNN Consulting & Development</span>
<ul class="fly-out">
<li>
<span>Jobs in Rock County Case Study</span>
</li>
</ul>
</li>
<li>
<span>Website Hosting</span>
<ul class="fly-out">
<li>
<span>Site Security</span>
</li>
</ul>
</li>
<li>
<span>What Is Custom Design?</span>
</li>
<li>
<span>Conversion Rate Optimization</span>
</li>
</ul>
</li>
<li>
<span>App Development</span>
</li>
<li>
<span>Marketing Automation</span>
</li>
<li>
<span>Online Marketing</span>
<ul class="fly-out">
<li>
<span>Search Engine Optimization</span>
</li>
<li>
<span>Paid Search Marketing</span>
</li>
<li>
<span>Local SEO for Businesses</span>
</li>
<li>
<span>Social Media Marketing</span>
<ul class="fly-out">
<li>
<span>Social Media Services</span>
</li>
</ul>
</li>
<li>
<span>Conversion Rate Optimization</span>
</li>
<li>
<span>Email Marketing</span>
</li>
</ul>
</li>
<li>
<span>ADA Compliance Websites</span>
</li>
</ul>
</li>
<li>
<span>Our Work</span>
<ul class="drop-down">
<li>
<span>Manufacturing</span>
</li>
<li>
<span>E-Commerce</span>
</li>
<li>
<span>Health & Wellness</span>
</li>
<li>
<span>Business Services</span>
</li>
<li>
<span>Government & Non-Profit</span>
</li>
<li>
<span>Print</span>
</li>
</ul>
</li>
<li>
<span>Resources</span>
<ul class="drop-down">
<li>
<span>Blog</span>
</li>
<li>
<span>Tools</span>
<ul class="fly-out">
<li>
<span>Responsive Site Test</span>
</li>
<li>
<span>Conversion & Traffic Calculator</span>
</li>
<li>
<span>Website Design RFP</span>
</li>
<li>
<span>Google Review Generator</span>
</li>
<li>
<span>Project Estimator</span>
</li>
</ul>
</li>
<li>
<span>Support</span>
<ul class="fly-out">
<li>
<span>FTP Request</span>
</li>
<li>
<span>Submit a Ticket</span>
</li>
<li>
<span>Terms Of Service</span>
</li>
<li>
<span>SEO Tutorials</span>
<ul class="fly-out">
<li>
<span>Introduction To Analytics</span>
</li>
</ul>
</li>
<li>
<span>CMS Tutorials</span>
</li>
<li>
<span>Website Design RFP</span>
</li>
</ul>
</li>
<li>
<span>Business Partners</span>
</li>
<li>
<span>FAQs</span>
</li>
<li>
<span>Plugins and Modules</span>
</li>
<li>
<span>Case Studies</span>
</li>
<li>
<span>eBooks/Webinars</span>
</li>
</ul>
</li>
<li>
<span>Company</span>
<ul class="drop-down">
<li>
<span>Testimonials</span>
</li>
<li>
<span>Community Involvement</span>
</li>
<li>
<span>News</span>
</li>
<li>
<span>Careers</span>
</li>
<li>
<span>Meet Our Team</span>
</li>
</ul>
</li>
<li>
<span>Contact</span>
</li>
</ul>
</nav>
And here is the CSS:
$nav-dark: rgb(34, 34, 34);
$nav-light: rgb(240, 255, 240);
$menu-green-dark: rgb(91, 146, 121);
$menu-green: rgb(138, 178, 153);
$menu-green-light: rgb(150, 194, 174);
//outer list
.top-level{
list-style-type: none;
margin: 0px;
padding: 0px;
top: 0px;
left: 0px;
position: fixed;
//overflow: hidden;
}
//make dropdown visible on hovering
//top-level list item
.top-level li:hover .drop-down{
visibility: visible;
display: block;
}
//list inside .top-level
.drop-down{
list-style-type: none;
overflow: visible;
margin-top: 6px;
padding: 0px;
visibility: hidden;
position: fixed;
display:none;
}
//lists inside dropdown or other flyouts
.fly-out{
list-style-type: none;
overflow: visible;
margin: 0px;
padding: 0px;
top: 0;
left: 100%;
position: fixed;
}
//make flyout visible on hovering
//.drop-down list item
.drop-down li:hover .fly-out{
display: block;
visibility: visible;
}
//inside lists
.drop-down li .fly-out{
display: none;
visibility: hidden;
position: relative;
}
.fly-out li .fly-out li{
display: none;
visibility: hidden;
}
.fly-out li:hover .fly-out li{
display: block;
visibility: visible;
position: relative;
background-color: $menu-green-light;
}
//outer list item's text
.top-level li > a,
.top-level li > span {
padding: 4px;
display: block;
color: $nav-light
}
//headers for list items inside .top-level
.drop-down li > a,
.drop-down li > span {
color: $nav-light;
}
//headers for list items inside .top-level
.fly-out li > a,
.fly-out li > span {
color: $nav-light;
}
//outer list items
.top-level > li{
float: left;
background-color: $nav-dark;
padding: 6px;
}
//list items inside .top-level
.drop-down > li{
background-color: $menu-green-dark;
}
.fly-out > li{
background-color: $menu-green;
}
Right now I am wondering if has something to do with my use of display: none/block to make things appear and come back, but I can't really say for sure.
If its easier here is a link to the codepen where I am working on it.
Since your code is too long, I have created a similar structure so that it is easier to understand. You should use absolute positioning relative to the parent <li> to align the dropdowns.
a {
text-decoration: none;
color: inherit;
}
ul {
list-style: none;
padding-left: 0;
width: 240px;
display: flex;
justify-content: space-between;
background: #333;
color: #fff;
}
li {
padding: 1em;
}
li:hover {
background: #444;
}
.submenu {
display: none;
position: absolute;
top: 3em;
left: 0;
}
.submenu:hover {
display: block;
}
.submenu-header {
position: relative;
}
.submenu-header:hover>.submenu {
display: block;
}
.sub-submenu {
display: none;
position: absolute;
top: 0;
left: 240px;
}
.sub-submenu:hover {
display: block;
}
.sub-submenu-header {
position: relative;
}
.sub-submenu-header:hover>.sub-submenu {
display: block;
}
<nav>
<ul>
<li>Link1</li>
<li class='submenu-header'>
Link2
<ul class='submenu'>
<li>link4</li>
<li class='sub-submenu-header'>
link5
<ul class="sub-submenu">
<li>link7</li>
<li>link8</li>
</ul>
</li>
<li>link6</li>
</ul>
</li>
<li>Link3</li>
</ul>
</nav>
You can check my codepen here.

How to make a hoverable drop-down navigation menu with multiple sub-menus?

I was practicing to make a hoverable drop-down navigation bar with multiple sub-menus.
Here's the [code][1] for what I did.
[1]:
header {
background: #333;
position: fixed;
width: 100%;
}
.navlogo {
height: 80px;
width: 80px;
}
.navbar .menu li {
display: inline;
position: relative;
padding: 10px;
}
.navbar .menu li a,
.navbar .menu li .submenu li a,
.navbar .menu li .submenu li .subsubmenu li a {
color: white;
text-decoration: none;
}
.navbar .menu li .submenu {
display: none;
}
.navbar .menu li:hover .submenu {
display: block;
position: absolute;
background: #333;
top: 100%;
}
.navbar .menu li:hover .submenu li .subsubmenu {
display: none;
}
.navbar .menu li:hover .submenu li:hover .subsubmenu {
display: block;
position: absolute;
background: #333;
top: 100%;
}
<header>
<nav class="navbar" id="navbar">
<ul class="menu" id="menu">
<li>
<img src="" alt="Home" id="navlogo">
</li>
<li>
Android
<ul class="submenu" id="submenu">
<li>Tricks</li>
<li>Solved Problems</li>
</ul>
</li>
<li>
Windows
<ul class="submenu" id="submenu">
<li>Tricks</li>
<li>Solved Problems</li>
</ul>
</li>
<li>
Linux
<ul class="submenu" id="submenu">
<li>Tricks</li>
<li>Solved Problems</li>
</ul>
</li>
<li>
Gaming
<ul class="submenu" id="submenu">
<li>
Android
<ul class="subsubmenu" id="subsubmenu">
<li>Gameplay</li>
<li>Walkthroughs</li>
<li>Tips</li>
<li>Reviews</li>
</ul>
</li>
<li>
Windows
<ul class="subsubmenu" id="subsubmenu">
<li>Gameplay</li>
<li>Walkthroughs</li>
<li>Tips</li>
<li>Reviews</li>
</ul>
</li>
<li>
Linux
<ul class="subsubmenu" id="subsubmenu">
<li>Tips</li>
</ul>
</li>
<li>iOS</li>
</ul>
</li>
<li>
Entertainment
<ul class="submenu" id="submenu">
<li>
Movies
<ul class="subsubmenu" id="subsubmenu">
<li>Reviews</li>
<li>Downloads</li>
</ul>
</li>
<li>
Shows
<ul class="subsubmenu" id="subsubmenu">
<li>Reviews</li>
<li>Downloads</li>
</ul>
</li>
</ul>
</li>
<li>
Education
<ul class="submenu" id="submenu">
<li>Programming</li>
<li>Maths</li>
<li>Science</li>
<li>Mental Ability</li>
<li>Languages</li>
</ul>
</li>
<li>Ask</li>
</ul>
</nav>
</header>
Problems
All the sub-menu links on hover are displaying in one place only instead of displaying below the hovered link.
I am not able to style the sub-menus correctly. Like how to make Solved Problems link appear in one line. And then except Android's Sub menu all other are displaying as inline(I think!).
How to make the spacing look like this ? Basically I want my sub-menus to look like the style given in the shared tutorial.

white space in navigation

I want to make this navigation that it looks like in tiled format. But here some white spaces coming at the end of the one row. Is it possible to make it form like a border surrounded by navigation & inside it navigation looks like proper tiles instead of some white space..
My Code..
.nav {
width: 960px;
margin: 50px auto;
border: 1px solid #06c;
display: table
}
.nav ul {
padding: 0;
margin: 0
}
.nav ul li {
list-style: none;
float: left;
border: 1px solid #06C;
font-family: Swis721 Cn BT;
font-weight: bold;
display: block
}
.nav ul li a {
text-decoration: none;
color: #06C;
padding: 10px 20px 10px 12px;
display: block
}
.nav ul li a:hover {
color: #fff;
background: #06c
}
<div class="nav">
<ul>
<li>ALL
</li>
<li>AGENCY
</li>
<li>AUTOMOBILES
</li>
<li>BANKING
</li>
<li>CONSUMER DURABLE & FMCG
</li>
<li>CONSULTING
</li>
<li>EDUCATIONAL
</li>
<li>FINANCIAL SERVICES
</li>
<li>HOSPITALITY
</li>
<li>INFRASTRUCTURE & REAL ESTATE
</li>
<li>INTERNATIONAL
</li>
<li>IT
</li>
<li>LEGAL
</li>
<li>MANFACTURING
</li>
<li>MARINE
</li>
<li>MEDIA
</li>
<li>OIL & GAS
</li>
<li>ONLINE
</li>
<li>OTHERS
</li>
<li>PHARMA
</li>
<li>RETAIL
</li>
<li>THEME PARK
</li>
</ul>
</div>
Probably this will work as i have given some special styles (css) to some 'li' however this will not provide 100% output as you want but still effective in such case..
.nav {
width: 970px;
margin: 50px auto;
border:0px solid;
display: table
}
.nav ul {
padding: 0;
margin: 0
}
.nav ul li {
list-style: none;
float: left;
border: 1px solid #06C;
font-family: Swis721 Cn BT;
font-weight: bold;
display: block;
min-width:5%;
width:auto;
text-align:center
}
.nav ul li a {
text-decoration: none;
color: #06C;
padding: 10px 20px 10px 12px;
display: block
}
.nav ul li a:hover {
color: #fff;
background: #06c
}
<div class="nav">
<ul>
<li>ALL
</li>
<li>AGENCY
</li>
<li>AUTOMOBILES
</li>
<li>BANKING
</li>
<li>CONSUMER DURABLE & FMCG
</li>
<li>CONSULTING
</li>
<li style="width:25%">EDUCATIONAL
</li>
<li>FINANCIAL SERVICES
</li>
<li>HOSPITALITY
</li>
<li>THEME PARK
</li>
<li>INTERNATIONAL
</li>
<li>IT
</li>
<li>LEGAL
</li>
<li>MANFACTURING
</li>
<li style="width:15%">MARINE
</li>
<li>MEDIA
</li>
<li>OIL & GAS
</li>
<li>ONLINE
</li>
<li>OTHERS
</li>
<li>PHARMA
</li>
<li>RETAIL
</li>
<li style="width:45%">INFRASTRUCTURE & REAL ESTATE
</li>
</ul>
</div>
Note : Keep in mind the output will be different in such case like change of fonts, or any navigation position change other than it is written now..
you can use this
.nav{
border:0px solid;
}
.nav ul li{
width:25%;/*according to your need you can increase or decrease*/
}
.nav ul {
padding: 0;
margin: 0
}
.nav {
width: 960px;
margin: 50px auto;
border: 1px solid #06c;
display: table;
padding: 0px 0px;
font-size: 100%;
}
.nav ul li {
list-style: none;
float: left;
border: 1px solid #06C;
font-family: sans-serif;
font-weight: bold;
min-width: 7.8%;
width: auto;
font-size: inherit;
text-align: center;
}
.nav ul li a {
text-decoration: none;
color: #06C;
adding: 10px 12px 10px 12px;
display: list-item;
WIDTH: AUTO;
min-width: 100%;
box-sizing: border-box;
}
.nav ul li a:hover {
color: #fff;
background: #06c
}
<div class="nav">
<ul>
<li>ALL
</li>
<li>AGENCY
</li>
<li>AUTOMOBILES
</li>
<li>BANKING
</li>
<li>CONSUMER DURABLE & FMCG
</li>
<li>CONSULTING
</li>
<li>EDUCATIONAL
</li>
<li>FINANCIAL SERVICES
</li>
<li>HOSPITALITY
</li>
<li>INFRASTRUCTURE & REAL ESTATE
</li>
<li>INTERNATIONAL
</li>
<li>IT
</li>
<li>LEGAL
</li>
<li>MANFACTURING
</li>
<li>MARINE
</li>
<li>MEDIA
</li>
<li>OIL & GAS
</li>
<li>ONLINE
</li>
<li>OTHERS
</li>
<li>PHARMA
</li>
<li>RETAIL
</li>
<li>THEME PARK
</li>
</ul>
</div>

triple tier drop down menu

I have been trying to make a menu that has 3 tiers, for example i want to hover over 'family' and be shown 'holidays' and 'day Trips'. Then I want to hover 'holidays' or 'day trips' and be shown the next options 'videos 1-3'. I have only been doing HTML5 and CSS3 for a few weeks so I am quite green. Any help would be great.
<ul id="menu2">
<li> Family
<ul class="sub-menu2">
<li>Holidays
<li> Video 1 </li>
<li> Video 2 </li>
<li> Video 3 </li>
</li>
<li>Day Trips
<li> Video 1 </li>
<li> Video 2 </li>
<li> Video 3 </li>
</li>
</ul>
</li>
</ul>
CSS
#menu2, ul#menu2 ul.sub-menu2 {
padding:0;
margin-top: -41px;
}
#menu2 li, ul#menu2 ul.sub-menu2 li {
list-style-type: none;
display: inline-block;
width:100px;
left:73%;
margin-bottom:4px;
}
#menu2 li a, ul#menu2 li ul.sub-menu2 li a {
text-decoration: none;
text-align:center;
color: yellow;
background: black;
padding: 5px;
display:inline-block;
width:100px;
border-bottom-right-radius:20px;
border-top-left-radius: 20px;
border: 2px solid yellow;
}
#menu2 li {
position: relative;
}
#menu2 li ul.sub-menu2 {
display:none;
position: absolute;
top: 30px;
right: 72px;
width: auto;
margin-top:6px;
margin-bottom:-2px;
}
#menu2 li:hover ul.sub-menu2 {
display:block;
}
#menu2 li ul.sub-menu2 a:hover {
background-color: yellow;
color: black;
}
Your structure is not correct. It should be like this:
<ul id="menu2">
<li>Family
<ul class="sub-menu2">
<li>Holidays
<ul>
<li>Video 1</li>
<li>Video 2</li>
<li>Video 3</li>
</ul>
</li>
<li>Day Trips
<ul>
<li> Video 1 </li>
<li> Video 2 </li>
<li> Video 3 </li>
</ul>
</li>
</ul>
</li>
</ul>
And you have to modify your CSS a little bit. I made a little dummy here:
generic DEMO Fiddle

Remove right margin off one element in HTML/CSS List Navigation

I am trying to get the gray buttons at the top of this page to all fit across the top (in line with the body), rather than on two lines: http://www.nbm.org/test/nbm-online-drafts/dropdown-testing.html
I have it set up as a list:
<nav id="main-nav">
<ul id="nav-primary">
<li><img src="http://www.nbm.org/assets/images/homepage/2011/nav-sprites/planyourvisit.jpg" alt="Plan Your Visit" width="109" height="48">
<ul class="subnav">
<li>Buy Tickets
</li>
<li>Hours & Admission
</li>
<li>Accessibility & Directions
</li>
<li>Tours
</li>
</ul>
</li>
<li><img src="http://www.nbm.org/assets/images/homepage/2011/nav-sprites/exhibitionscollections.jpg" alt="Exhibitions / Collections" width="109" height="48">
<ul class="subnav">
<li>Current Exhibitions
</li>
<li>Upcoming Exhibitions
</li>
<li>Buy Tickets
</li>
<li>Collections
</li>
</ul>
</li>
<li><img src=" http://www.nbm.org/assets/images/homepage/2011/nav-sprites/adultprogs.jpg" alt="Adult Programs" width="109" height="48">
<ul class="subnav">
<li>Upcoming Programs
</li>
<li>Spotlight on Design
</li>
<li>Watch / Listen
</li>
<li>Continuing Education Credits
</li>
</ul>
</li>
<li><img src="http://www.nbm.org/assets/images/homepage/2011/nav-sprites/familiesteens.jpg" alt="Families / Teens" width="109" height="48">
<ul class="subnav">
<li>Festivals
</li>
<li>Everyday Activities
</li>
<li>Teens & Young Adults
</li>
<li>Summer Camp
</li>
<li>Scouts & Youth Groups
</li>
<li>Birthday Parties
</li>
</ul>
</li>
<li><img src="http://www.nbm.org/assets/images/homepage/2011/nav-sprites/schoolseducators.jpg" alt="Schools / Educators" width="109" height="48">
<ul class="subnav">
<li>For Educators
</li>
<li>For Teens & Young Adults
</li>
<li>Plan a School Visit
</li>
</ul>
</li>
<li><img src="http://www.nbm.org/assets/images/homepage/2011/nav-sprites/joindonate.jpg" alt="Join / Donate" width="109" height="48">
<ul class="subnav">
<li>Donate Now
</li>
<li>Membership
</li>
<li>Corporate Giving
</li>
<li>Awards & Honors
</li>
<li>Volunteer
</li>
</ul>
</li>
<li><img src="http://www.nbm.org/assets/images/homepage/2011/nav-sprites/shop.jpg" alt="Shop" width="109" height="48">
<ul class="subnav">
<li>Books
</li>
<li>Home
</li>
<li>Toys
</li>
<li>Museum
</li>
<li>Stationery
</li>
<li>Fashion
</li>
<li>Design
</li>
</ul>
</li>
<li><img src="http://www.nbm.org/assets/images/homepage/2011/nav-sprites/aboutus.jpg" alt="About Us" width="109" height="48">
<ul class="subnav">
<li>About the Museum
</li>
<li>E-newsletters
</li>
<li>Press Room
</li>
<li>Staff & Governance
</li>
<li>Employment & Internships
</li>
</ul>
</li>
</ul>
I want to keep the li right margin at 4px, but that pushes the "About Us" button to a second line. Changing the li right margin to 3px is too little and the buttons do not line up with the body on the right.
CSS:
#main-nav {
background: none repeat scroll 0 0 white;
height: 53px;
left: 0;
position: relative;
top: 128px;
width: 100%;
z-index: 11;
}
#main-nav .subnav {
background: none repeat scroll 0 0 #D7D6D4;
border: 0 solid #D4D5D6;
display: none;
left: 0;
list-style-type: none;
margin: 0;
padding: 0;
position: absolute;
top: 49px;
width: 109px;
z-index: 11;
}
#main-nav .subnav li {
border-bottom: 1px solid #EEEEEE;
display: block;
margin: 0;
}
#main-nav .subnav li a {
color: #000000;
font-size: 11px;
height: 18px;
padding: 6px 4px 19px;
width: 101px;
}
#main-nav .subnav li a:hover {
background: none repeat scroll 0 0 #BFBEBA;
width: 101px;
}
#nav-primary {
float: left;
list-style-type: none;
margin: 0;
padding: 0;
}
#nav-primary li {
float: left;
margin-right: 4px;
position: relative;
}
#nav-primary li a {
color: #000000;
float: left;
font-size: 13px;
font-weight: bold;
height: 48px;
line-height: 16px;
text-align: center;
text-decoration: none;
width: 109px;
}
#nav-primary li a:hover {
text-decoration: none;
}
#nav-primary li:hover .subnav {
display: block;
}
Is it possible to remove the right margin on the last li element? Or to hide it?
Any ideas are much appreciated!
It is this simple:
#nav-primary > li:last-child
{
margin-right:0;
}