My dropdown menu in my nav bar isn't aligning - html

I'm having trouble aligning my drop down menu in my nav bar, I've tried every suggestion out there. I've tried left, float: left, right, and pretty much everything else. I think it is possibly something interfering. The drop down menu has everything aligned from center to right of the parent menu item.
https://jsfiddle.net/ethacker/j7tgq95j/3/
My html code:
<header>
<nav>
<h1> Welcome to Mommy Madness</h1>
<ul>
<li class="parentMenu">Home
<ul class="sub-menu">
<li>About</li>
<li>Contact</li>
</ul>
</li>
<li class="parentMenu">Pregnancy
<!--
Gender Predictions:
Old Wive's Tale
Boy vs Girl- The Ramzi Method
-->
<ul class="sub-menu">
<li>Advice</li>
<li>Gender Predictions</li>
<li>Trying To Conceive</li>
</ul>
</li>
<li class="parentMenu">All About Baby
<ul class="sub-menu">
<li>Fetal Development</li>
<li>Guidelines </li>
<li> Milestones</li>
</ul>
</li>
<li class="parentMenu">Party Momma
<!--
Birthdays - Link to 1-10th bdays.
-->
<ul class="sub-menu">
<li>Pregnancy Announcement</li>
<li>Gender Reveal</li>
<li>Baby Shower</li>
<li>Birth Announcement</li>
<li> Birthdays</li>
</ul>
</li>
<li class="parentMenu">Stations
<ul class="sub-menu">
<li>Hospital Bag</li>
<li>Diaper Bag</li>
<li>Changing Station</li>
<li>Baby Gear</li>
</ul>
</li>
<li class="parentMenu">Memory Markers
<!--
Drop Down Menu:
DIY
Purchases
(Both to have holiday/event selectors on right of page)
-->
<ul class="sub-menu">
<li>DIY</li>
<li>Purchases</li>
</ul>
</li>
<li class="parentMenu">Reviews
<ul class="sub-menu">
<li>Games</li>
<li>Gear</li>
<li>Learning</li>
</ul>
</li>
<li class="parentMenu">Blog
<ul class="sub-menu">
<li>Fit Momma</li>
<li>Minimal Momma</li>
<li>Modern Momma</li>
<li>Organic Momma</li>
<li>Organizing Queen</li>
<li>Savings Savvy</li>
<li>Tech Savvy</li>
<li>Traditional Momma</li>
</ul>
</li>
</ul>
</nav>
My css code:
body {
background-color: beige;
color: lightblue;
padding: 0;
margin:0;
}
header {
background-color: lightblue;
padding: 5px 0;
margin: 0;
}
header h1 {
color: cadetblue;
font-family: Arial;
margin: 0;
padding: 5px 15px;
display: inline;
}
.navMenu{
display: inline;
margin: 0;
}
.navMenu .parentMenu {
display: inline-block;
list-style-type: none;
background-color: lightgray;
padding: 5px 10px;
border: thin solid darkgray;
border-radius: 3px;
color: honeydew;
position: relative;
margin: 0;
}
.navMenu .parentMenu a{
color: azure;
}
.navMenu .parentMenu .sub-menu{
display: none;
}
.navMenu .parentMenu:hover .sub-menu{
display: block;
position: absolute;
list-style-type: none;
margin:0;
}
.parentMenu:hover .sub-menu li{
border: thin solid darkgray;
padding: 4%;
background-color: lightgray;
color: honeydew;
text-align: left;
white-space: nowrap;
width: 100%;
list-style-type: none;
margin: 0;
}
.parentMenu .sub-menu li:hover {
background-color: lightsteelblue;
}
.section {
background-color: wheat;
color: darkslategray;
padding: 5px;
float: left;
display: inline;
width: 63%;
margin: 0 1% 1% 1%;
border-radius: 10px;
border: thin solid khaki;
box-shadow: lightgray;
}
#about {
float: right;
width: 30%;
margin: 1% 1% 0 0;
text-align: center;
}
#home{
margin: 1% 0 1% 1%;
}
h4, h3 {
color: lightseagreen;
}

This will align the submenu to the left:
.navMenu .parentMenu .sub-menu {
display: none;
position:absolute;
list-style-type: none;
padding:0;
margin: 0;
left:-1px;
top:27px;
}
.navMenu .parentMenu:hover .sub-menu {
display: block;
}
https://jsfiddle.net/am13qur4/

you did not specify where you want to align your drop down elements. Do you want to align all to the right, center or left. I assumed left so try adding the code below. You may need to adjust the left attribute's value and your hover background styling too.
.sub-menu a{
position: absolute;
left: 3%;
}
Let me know if this helps. Stay warm!

Related

Is there a way to have text appear below absolute element without adding a margin-top to the element?

I am making a multi-list dropdown navigation, and below that I want some text or a photo to be displayed. Since my navbar has a position of absolute, the text is appearing behind the navbar rather than below it. Is there a way that I can get my text to appear below without using a margin or padding on the element or container beneath the nav?
Currently the "fix" that I have been using is to add a style of margin-top: 4rem or the same with padding to my h1 to get it to show under the nav rather than behind it.
Since I want to use this navigation bar on multiple pages though with differing content, I am hoping to not need to continuously find the element below the navigation and add that padding/margin to it. Is there any other way or do I just need to use the current "solution"?
Here is my codepen
Snippet below:
html,
body {
margin: 0;
padding: 0;
}
header {
height: 100px;
background: black;
}
nav {
position: absolute;
left: 0px;
right: 0px;
width: 100%;
background: #363636;
}
nav .nav-container {
width: 80%;
margin: auto;
}
nav .third-level-menu {
list-style-type: none;
position: absolute;
top: 0;
right: -15rem;
width: 15rem;
list-style: none;
padding: 0;
margin: 0;
display: none;
}
nav .third-level-menu > li {
height: auto;
background: #414141;
}
nav .second-level-menu {
list-style-type: none;
position: absolute;
top: 4rem;
left: 0;
width: 15rem;
list-style: none;
padding: 0;
margin: 0;
display: none;
font-size: 0.5rem;
letter-spacing: 0.1ch;
text-indent: 1rem;
font-size: 1rem;
}
nav .second-level-menu > li {
list-style-type: none;
position: relative;
height: 4rem;
background: #474747;
text-align: left;
}
nav .top-level-menu {
list-style-type: none;
list-style: none;
padding: 0;
margin: 0;
float: left;
line-height: normal;
text-align: center;
height: auto;
}
nav .top-level-menu > li {
position: relative;
float: left;
height: 4rem;
width: 9.4rem;
background: #363636;
font-size: 1.2rem;
}
nav .top-level-menu a {
color: #e8e8e8;
text-decoration: none;
padding: 0 1rem;
display: block;
line-height: 4rem;
text-transform: uppercase;
}
#media screen and (min-width: 1023px) {
.top-level-menu li:hover > ul {
display: inline;
}
}
<header>
</header>
<nav class="nav">
<div class="nav-container">
<ul class="top-level-menu">
<li>Home</li>
<li>
More
<ul class="second-level-menu">
<li>
<a>Wyoming</a>
<ul class="third-level-menu">
<li>Wyoming li</li>
<li>Wyoming li</li>
<li>Wyoming li</li>
<li>Wyoming li</li>
</ul>
</li>
<li>
<a>Washington</a>
<ul class="third-level-menu">
<li>Washington</li>
<li>Washington</li>
</ul>
</li>
<li>
<a>Idaho</a>
<ul class="third-level-menu">
<li>Idaho Falls</li>
<li>Idaho Falls</li>
<li>Idaho Falls</li>
<li>Idaho Falls</li>
<li>Idaho Falls</li>
<li>Idaho Falls</li>
</ul>
</li>
<li>
<a>Minnesota</a>
<ul class="third-level-menu">
<li>Duluth</li>
</ul>
</li>
<li>
<a>Montana</a>
<ul class="third-level-menu">
<li>Montana</li>
<li>Montana</li>
<li>Montana</li>
<li>Montana</li>
</ul>
</li>
<li>
<a>South Dakota</a>
<ul class="third-level-menu">
<li>SD</li>
<li>SD</li>
</ul>
</li>
<li>
<a>North Dakota</a>
<ul class="third-level-menu">
<li>Idaho</li>
<li>Idaho</li>
<li>Idaho</li>
<li>Idaho</li>
<li>Idaho</li>
</ul>
</li>
</ul>
</li>
<li>
Sale
<ul class="second-level-menu">
<li>Ogden, UT</li>
<li>Ogden, UT</li>
<li>Ogden, UT</li>
<li>Ogden, UT</li>
</ul>
</li>
<li>Contact</li>
<li>About</li>
</ul>
</div>
</nav>
<br>
<h1>HELLO IS ANYONE THERE?</h1>
I added a div with an id of 'navspace'. This will need to be added to every page underneath the nav.
Then I added a line of javascript which makes this div the same height as the nav. All other elements will therefore appear below the nav.
document.getElementById("navspace").style.height = document.getElementsByTagName('nav')[0].offsetHeight + "px";
html,
body {
margin: 0;
padding: 0;
}
header {
height: 100px;
background: black;
}
nav {
position: absolute;
left: 0px;
right: 0px;
width: 100%;
background: #363636;
}
nav .nav-container {
width: 80%;
margin: auto;
}
nav .third-level-menu {
list-style-type: none;
position: absolute;
top: 0;
right: -15rem;
width: 15rem;
list-style: none;
padding: 0;
margin: 0;
display: none;
}
nav .third-level-menu>li {
height: auto;
background: #414141;
}
nav .second-level-menu {
list-style-type: none;
position: absolute;
top: 4rem;
left: 0;
width: 15rem;
list-style: none;
padding: 0;
margin: 0;
display: none;
font-size: 0.5rem;
letter-spacing: 0.1ch;
text-indent: 1rem;
font-size: 1rem;
}
nav .second-level-menu>li {
list-style-type: none;
position: relative;
height: 4rem;
background: #474747;
text-align: left;
}
nav .top-level-menu {
list-style-type: none;
list-style: none;
padding: 0;
margin: 0;
float: left;
line-height: normal;
text-align: center;
height: auto;
}
nav .top-level-menu>li {
position: relative;
float: left;
height: 4rem;
width: 9.4rem;
background: #363636;
font-size: 1.2rem;
}
nav .top-level-menu a {
color: #e8e8e8;
text-decoration: none;
padding: 0 1rem;
display: block;
line-height: 4rem;
text-transform: uppercase;
}
#media screen and (min-width: 1023px) {
.top-level-menu li:hover>ul {
display: inline;
}
}
<header>
</header>
<nav class="nav">
<div class="nav-container">
<ul class="top-level-menu">
<li>Home</li>
<li>
More
<ul class="second-level-menu">
<li>
<a>Wyoming</a>
<ul class="third-level-menu">
<li>Wyoming li</li>
<li>Wyoming li</li>
<li>Wyoming li</li>
<li>Wyoming li</li>
</ul>
</li>
<li>
<a>Washington</a>
<ul class="third-level-menu">
<li>Washington</li>
<li>Washington</li>
</ul>
</li>
<li>
<a>Idaho</a>
<ul class="third-level-menu">
<li>Idaho Falls</li>
<li>Idaho Falls</li>
<li>Idaho Falls</li>
<li>Idaho Falls</li>
<li>Idaho Falls</li>
<li>Idaho Falls</li>
</ul>
</li>
<li>
<a>Minnesota</a>
<ul class="third-level-menu">
<li>Duluth</li>
</ul>
</li>
<li>
<a>Montana</a>
<ul class="third-level-menu">
<li>Montana</li>
<li>Montana</li>
<li>Montana</li>
<li>Montana</li>
</ul>
</li>
<li>
<a>South Dakota</a>
<ul class="third-level-menu">
<li>SD</li>
<li>SD</li>
</ul>
</li>
<li>
<a>North Dakota</a>
<ul class="third-level-menu">
<li>Idaho</li>
<li>Idaho</li>
<li>Idaho</li>
<li>Idaho</li>
<li>Idaho</li>
</ul>
</li>
</ul>
</li>
<li>
Sale
<ul class="second-level-menu">
<li>Ogden, UT</li>
<li>Ogden, UT</li>
<li>Ogden, UT</li>
<li>Ogden, UT</li>
</ul>
</li>
<li>Contact</li>
<li>About</li>
</ul>
</div>
</nav>
<div id="navspace"></div>
<br>
<h1>HELLO IS ANYONE THERE?</h1>

Issue in overlapping of items in hoverable dropdown menu

I am trying to make a hoverable dropdown menu and the items of the dropdown are overlapped. I don't know how the CSS should be, but I tried to modify each class, but still doesn't work.
I also tried to modify the display of links, but that doesn't work. Here is the code I made:
<style>
#menu
{
margin:0;
font-size: 30px;
border-bottom: 1px solid;
text-align: center;
}
#menu a
{
color:#900;
text-decoration:none;
}
#menu .subitem a{
display: block;
padding: 12px 16px;
z-index: 1;
background-color: #f1f1f1;
border-bottom: 1px solid;
}
#menu a:hover
{
text-decoration:underline;
}
.item{
position: relative;
display: inline-block;
border-right: 0.5px solid;
padding-right: 30px;
padding-left: 30px;
}
.subitem{
display: none;
position: absolute;
background-color: #f1f1f1;
min-width: 160px;
left: 0;
z-index: 1;
}
#menu .item:hover .subitem{
display: block;
}
</style>
<div id="navWrapper">
<ul id="menu">
<li class="item">Small Things
<ul class="submenu">
<li class="subitem">Gnomes</li>
<li class="subitem">Fairies</li>
<li class="subitem">Elves</li>
<li class="subitem">Leprechauns</li>
</ul>
</li>
<li class="item">Big Things
<ul class="submenu">
<li class="subitem">Loch Ness Monster</li>
<li class="subitem">Ogres</li>
<li class="subitem">Giants</li>
<li class="subitem">Dragons</li>
</ul>
</li>
</ul>
</div>
I want to display properly each item when I hover with the mouse like it is in this
image.
You confused your .submenu with .subitem:
#menu
{
margin:0;
font-size: 30px;
border-bottom: 1px solid;
text-align: center;
}
#menu a
{
color:#900;
text-decoration:none;
}
#menu .subitem a{
display: block;
padding: 12px 16px;
z-index: 1;
background-color: #f1f1f1;
border-bottom: 1px solid;
}
#menu a:hover
{
text-decoration:underline;
}
.item{
position: relative;
display: inline-block;
border-right: 0.5px solid;
padding-right: 30px;
padding-left: 30px;
}
.subitem {
/* display: none; <- get rid of that */
/* position: absolute; <- get rid of that, otherwise all your subitems will be in the top left corner */
background-color: #f1f1f1;
min-width: 160px;
left: 0;
z-index: 1;
}
.submenu {
position: absolute; /* <- put it here */
display: none; /* <- put it here */
list-style-type: none;
left:-40px;
top: 30px;
}
#menu .item:hover .submenu {
display: block;
}
<div id="navWrapper">
<ul id="menu">
<li class="item">Small Things
<ul class="submenu">
<li class="subitem">Gnomes</li>
<li class="subitem">Fairies</li>
<li class="subitem">Elves</li>
<li class="subitem">Leprechauns</li>
</ul>
</li>
<li class="item">Big Things
<ul class="submenu">
<li class="subitem">Loch Ness Monster</li>
<li class="subitem">Ogres</li>
<li class="subitem">Giants</li>
<li class="subitem">Dragons</li>
</ul>
</li>
</ul>
</div>

Navigation looks wrong when it's fixed

I want the position of my navigation to be fixed. But when I change the position to "fixed" in nav, it looks very weird.
Here are two examples:
Without fixed position: https://jsfiddle.net/Timowo/3nrvch3c/
<nav>
<ul>
<li class="category">Contact</li>
<li class="category">Work</li>
<li class="category active">Home</li>
<li class="logotext">Logo</li>
</ul>
</nav>
With fixed position: https://jsfiddle.net/Timowo/5aock5k1/
<nav style="position: fixed;">
<ul>
<li class="category">Contact</li>
<li class="category">Work</li>
<li class="category active">Home</li>
<li class="logotext">Logo</li>
</ul>
</nav>
What do I have to change so it's inline but also fixed?
Thanks!
With position:fixed the element will collapse to the width of the widest descendant..in the absence of a defined width.
Just set width:100%
* {
box-sizing: border-box;
}
body {
margin: 0 auto;
background-color: red;
}
nav {
transition: all 0.2s ease-in-out;
position: fixed;
width: 100%;
}
nav ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: transparent;
}
nav ul li.logo {
padding: 14px;
float: left;
}
nav ul li.logotext {
font-family: Futura;
color: white;
font-size: 1.3em;
padding: 28px;
text-shadow: 3px 3px black;
}
nav ul li.category a {
display: block;
color: white;
text-align: center;
padding: 30px 20px;
text-decoration: none;
font-size: 1.2em;
float: right;
font-family: Futura;
text-shadow: 3px 3px black;
}
nav ul li.category:hover a {
background-color: #212121;
}
nav ul li.active a {
background-color: #212121;
}
<nav>
<ul>
<li class="category">Contact
</li>
<li class="category">Work
</li>
<li class="category active">Home
</li>
<li class="logotext">Logo</li>
</ul>
</nav>

Replace navigation bar color with an image's

This is how navigation bar image looks like:
Code Snippet
main nav #wrap {
width: 100%;
height: 50px;
margin: 0;
z-index: 2;
position: relative;
background-color: #3a3a3a; }
main nav #wrap .navbar {
height: 40px;
padding: 0;
margin: 0;
position: absolute; }
main nav #wrap .navbar li {
height: auto;
width: 150px;
float: left;
text-align: center;
list-style: none;
font: normal bold 12px/1.2em Arial, Verdana, Helvetica;
padding: 0;
margin: 0;
top: 20px;
background: #3a3a3a; }
main nav #wrap .navbar a {
padding: 18px 0;
text-decoration: none;
color: white;
display: block; }
main nav #wrap .navbar li:hover, main nav #wrap .navbar a:hover {
background-color: #54879d; }
main nav #wrap .navbar li ul {
display: none;
height: auto;
margin: 0;
padding: 0; }
main nav #wrap .navbar li:hover ul {
display: block; }
main nav #wrap .navbar li ul li {
background-color: #54879d; }
main nav #wrap .navbar li ul li a {
border-left: 1px solid #1f5065;
border-right: 1px solid #1f5065;
border-top: 1px solid #74a3b7;
border-bottom: 1px solid #1f5065; }
<main>
<nav>
<div id="wrap">
<ul class="navbar">
<li>Home</li>
<li>Retrievals
<ul>
<li>Data Listing</li>
<li>Web Scheduling</li>
<li>Google Maps Application</li>
</ul>
</li>
<li>Reporting
<ul>
<li><a href="#" >Ad Hoc Report</a></li>
<li>Drill Down Report</li>
<li>Ranking Report</li>
</ul>
</li>
<li>Business Intelligence
<ul>
<li>Business Dashboard</li>
<li>Web Pivot Table</li>
<li>Interactive Report</li>
<li>What-If Analysis</li>
</ul>
</li>
<li>Data Maintenance
<ul>
<li>Database CRUD</li>
<li>Database Update</li>
<li>Order Entry</li>
<li>Drag-and-Drop Application</li>
</ul>
</li>
<li>B2B Portal
<ul>
<li>B2B Portal</li>
<li>Secure Data-Driven Listings</li>
<li>Secure Shopping Cart</li>
</ul>
</li>
</ul>
</div>
</nav>
</main>
I have this navigation bar and I am trying to replace that gray color with the one of the above attached image. As you can see, it is not a simple color. It has small transparent dots.
Is there anyway I can copy that color?
PS: I do not want to use the image.
As I mentioned on my comment, there's no css method for adding noise. However, you can embed images in html by base64 encoding them. I've pinched the code from this answer, it's transparent so can be applied over any colour. If you need a different level/style of noise then you'll have to create it and base64 encode it (a simple google search will bring plenty of options).
Anyway, hope this helps!
main nav #wrap {
width: 100%;
height: 50px;
margin: 0;
z-index: 2;
position: relative;
background-color: #3a3a3a;
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAMAAAAp4XiDAAAAUVBMVEWFhYWDg4N3d3dtbW17e3t1dXWBgYGHh4d5eXlzc3OLi4ubm5uVlZWPj4+NjY19fX2JiYl/f39ra2uRkZGZmZlpaWmXl5dvb29xcXGTk5NnZ2c8TV1mAAAAG3RSTlNAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEAvEOwtAAAFVklEQVR4XpWWB67c2BUFb3g557T/hRo9/WUMZHlgr4Bg8Z4qQgQJlHI4A8SzFVrapvmTF9O7dmYRFZ60YiBhJRCgh1FYhiLAmdvX0CzTOpNE77ME0Zty/nWWzchDtiqrmQDeuv3powQ5ta2eN0FY0InkqDD73lT9c9lEzwUNqgFHs9VQce3TVClFCQrSTfOiYkVJQBmpbq2L6iZavPnAPcoU0dSw0SUTqz/GtrGuXfbyyBniKykOWQWGqwwMA7QiYAxi+IlPdqo+hYHnUt5ZPfnsHJyNiDtnpJyayNBkF6cWoYGAMY92U2hXHF/C1M8uP/ZtYdiuj26UdAdQQSXQErwSOMzt/XWRWAz5GuSBIkwG1H3FabJ2OsUOUhGC6tK4EMtJO0ttC6IBD3kM0ve0tJwMdSfjZo+EEISaeTr9P3wYrGjXqyC1krcKdhMpxEnt5JetoulscpyzhXN5FRpuPHvbeQaKxFAEB6EN+cYN6xD7RYGpXpNndMmZgM5Dcs3YSNFDHUo2LGfZuukSWyUYirJAdYbF3MfqEKmjM+I2EfhA94iG3L7uKrR+GdWD73ydlIB+6hgref1QTlmgmbM3/LeX5GI1Ux1RWpgxpLuZ2+I+IjzZ8wqE4nilvQdkUdfhzI5QDWy+kw5Wgg2pGpeEVeCCA7b85BO3F9DzxB3cdqvBzWcmzbyMiqhzuYqtHRVG2y4x+KOlnyqla8AoWW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Fq0JSiPfPDQdnt+4/wuqcXY47QILbgAAAABJRU5ErkJggg==);
}
main nav #wrap .navbar {
height: 40px;
padding: 0;
margin: 0;
position: absolute;
}
main nav #wrap .navbar li {
height: auto;
width: 150px;
float: left;
text-align: center;
list-style: none;
font: normal bold 12px/1.2em Arial, Verdana, Helvetica;
padding: 0;
margin: 0;
top: 20px;
background-color: #3a3a3a;
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAMAAAAp4XiDAAAAUVBMVEWFhYWDg4N3d3dtbW17e3t1dXWBgYGHh4d5eXlzc3OLi4ubm5uVlZWPj4+NjY19fX2JiYl/f39ra2uRkZGZmZlpaWmXl5dvb29xcXGTk5NnZ2c8TV1mAAAAG3RSTlNAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEAvEOwtAAAFVklEQVR4XpWWB67c2BUFb3g557T/hRo9/WUMZHlgr4Bg8Z4qQgQJlHI4A8SzFVrapvmTF9O7dmYRFZ60YiBhJRCgh1FYhiLAmdvX0CzTOpNE77ME0Zty/nWWzchDtiqrmQDeuv3powQ5ta2eN0FY0InkqDD73lT9c9lEzwUNqgFHs9VQce3TVClFCQrSTfOiYkVJQBmpbq2L6iZavPnAPcoU0dSw0SUTqz/GtrGuXfbyyBniKykOWQWGqwwMA7QiYAxi+IlPdqo+hYHnUt5ZPfnsHJyNiDtnpJyayNBkF6cWoYGAMY92U2hXHF/C1M8uP/ZtYdiuj26UdAdQQSXQErwSOMzt/XWRWAz5GuSBIkwG1H3FabJ2OsUOUhGC6tK4EMtJO0ttC6IBD3kM0ve0tJwMdSfjZo+EEISaeTr9P3wYrGjXqyC1krcKdhMpxEnt5JetoulscpyzhXN5FRpuPHvbeQaKxFAEB6EN+cYN6xD7RYGpXpNndMmZgM5Dcs3YSNFDHUo2LGfZuukSWyUYirJAdYbF3MfqEKmjM+I2EfhA94iG3L7uKrR+GdWD73ydlIB+6hgref1QTlmgmbM3/LeX5GI1Ux1RWpgxpLuZ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ci1gWBCSGHtuV1H2mhSnO3Wp/3fEV5a+4wz//6qy8JxjZsmxxy5+4w9CDNJY09T072iKG0EnOS0arEYgXqYnXcYHwjTtUNAcMelOd4xpkoqiTYICWFq0JSiPfPDQdnt+4/wuqcXY47QILbgAAAABJRU5ErkJggg==);
}
main nav #wrap .navbar a {
padding: 18px 0;
text-decoration: none;
color: white;
display: block;
}
main nav #wrap .navbar li:hover,
main nav #wrap .navbar a:hover {
background-color: #54879d;
}
main nav #wrap .navbar li ul {
display: none;
height: auto;
margin: 0;
padding: 0;
}
main nav #wrap .navbar li:hover ul {
display: block;
}
main nav #wrap .navbar li ul li {
background-color: #54879d;
}
main nav #wrap .navbar li ul li a {
border-left: 1px solid #1f5065;
border-right: 1px solid #1f5065;
border-top: 1px solid #74a3b7;
border-bottom: 1px solid #1f5065;
}
<main>
<nav>
<div id="wrap">
<ul class="navbar">
<li>Home</li>
<li>Retrievals
<ul>
<li>Data Listing</li>
<li>Web Scheduling</li>
<li>Google Maps Application</li>
</ul>
</li>
<li>Reporting
<ul>
<li><a href="#" >Ad Hoc Report</a></li>
<li>Drill Down Report</li>
<li>Ranking Report</li>
</ul>
</li>
<li>Business Intelligence
<ul>
<li>Business Dashboard</li>
<li>Web Pivot Table</li>
<li>Interactive Report</li>
<li>What-If Analysis</li>
</ul>
</li>
<li>Data Maintenance
<ul>
<li>Database CRUD</li>
<li>Database Update</li>
<li>Order Entry</li>
<li>Drag-and-Drop Application</li>
</ul>
</li>
<li>B2B Portal
<ul>
<li>B2B Portal</li>
<li>Secure Data-Driven Listings</li>
<li>Secure Shopping Cart</li>
</ul>
</li>
</ul>
</div>
</nav>
</main>

HTML/CSS horizontal white space between divs

I have whitespace between two html sections that I would like to get rid of. Here is a picture of it:
I removed any whitespace in my html code between /div and div, as suggested by answers from my searches, but it didn't seem to fix the problem.
HTML Code:
<!--website main heading layout-->
<div id="heading">
<h1> Beat Your Pace <h1/>
<h2> The music search tool to boost your running performance! </h2>
</div><div id="topbar">
<!--topbar/menu layout-->
<div id="topbar_wrapper">
<ul id="mainmenu">
<li>Home</li><li>
Search</li><li>
Sort By &#9660
<ul id="sortmenu">
<li><a href='#'>Song</a>
<ul class="sortsubmenu">
<li><a href='#'>A to Z</a></li><li>
<a href='#'>Z to A</a></li>
</ul>
</li><li>
<a href='#'>Artist</a>
<ul class="sortsubmenu">
<li><a href='#'>A to Z</a></li><li>
<a href='#'>Z to A</a></li>
</ul>
</li><li>
<a href='#'>Album</a>
<ul class="sortsubmenu">
<li><a href='#'>A to Z</a></li><li>
<a href='#'>Z to A</a></li>
</ul>
</li><li>
<a href='#'>Genre</a>
<ul class="sortsubmenu">
<li><a href='#'>A to Z</a></li><li>
<a href='#'>Z to A</a></li>
</ul>
</li><li>
<a href='#'>BPM</a>
<ul class="sortsubmenu">
<li><a href='#'>Slowest to Fastest</a></li><li>
<a href='#'>Fastest to Slowest</a></li>
</ul>
</li><li>
<a href='#'>Release Date</a>
<ul class="sortsubmenu">
<li><a href='#'>Newest to Oldest</a></li><li>
<a href='#'>Oldest to Newest</a></li>
</ul>
</li>
</ul>
</li><li>
Add Song</li><li>
Contact Us</li>
</ul>
</div>
</div>
body and heading CSS Code:
html, body {
margin: 0px;
padding: 0px;
font-family: Arial;
font-size: 18px;
}
#heading {
background: url("http://cdn4.techlila.com/wp- content/uploads/2011/01/header2.jpg");
background-position: left;
color: black;
text-shadow: -1px 0 #F8F8FF, 0 1px #F8F8FF, 1px 0 #F8F8FF, 0 -1px #F8F8FF;
}
Menu CSS Code:
#topbar {
background-color: #222;
}
#topbar_wrapper {
width: 100%;
margin: 0 auto;
text-align: left;
}
#mainmenu {
list-style-type: none;
padding: 0px;
margin: 0px;
position: relative;
min-width: 200px;
}
#mainmenu > li {
display: inline-block;
width: 200px;
}
#mainmenu li:hover {
background-color: #333;
}
#mainmenu li a{
color: #CCC;
display: block;
padding: 15px;
text-decoration: none;
}
#mainmenu li:hover > ul {
display: block;
}
#sortmenu {
display: none;
position: absolute;
background-color: #333;
border: 5px solid #222;
border-top: 0;
margin-left: -5px;
}
#sortmenu > li {
display: block;
position: relative;
}
#sortmenu li a:hover {
color: #699;
}
#sortmenu li: hover ul {
display: inline-block;
}
.sortsubmenu {
display: none;
position: absolute;
background-color: #333;
border: 5px solid #222;
border-left: 0px;
text-align: right;
top: 0;
left: 100%;
width: auto;
}
.sortsubmenu li{
display: inline;
white-space: nowrap;
}
.sortsubmenu li a:hover {
color: #DB7093;
}
Remove the default on the <h2> element:
#heading h2 {
margin:0;
}