Nav bar is not showing on webpage

2019-03-07 01:15发布

问题:

I'm not sure where my navigation is. when i open using google chrome or IE the webpage has no navigation bar. Why is this and what do i need to fix?

html

<header class= 'main-header' >
               <div class="logo">
                    !# insert logo picture
               </div>
    <div id="nav">
               <ul id="nav">
                        <li><a href="/home/">Home</a></li>
                        <li><a href="/about/">About Us</a></li>
                        <li><a href="/news/">News & Events</a></li>
                        <li><a href="/classes/">Classes & Camps</a></li>
                        <li><a href="/gallery/">Gallery</a></li>
                        <li><a href="/contact/">Contact us</a></li>
                        <li><a href="/enrol/">Enrol Now</a></li>
                </ul>
          </div>
        </header> 

css

#content {
   width: 50em;
   margin: 0 auto;
   padding: 40px 0;

}

ul#nav {
    position: relative;
    list-style: none;
    margin: 0;
    padding: 0;

}

ul#nav li  {
    position: relative;
    float: left;
    display: inline-block;
    padding: 8px 5px 3px 5px;
    background-color: #FFF;
    text-decoration: none; 
    padding: .2em 1em;
}

any ideas? Note: im trying to place the navigator at the top of my webpage. Also I have placed it on a header, could it simply be beneath it?

css for header

.main-header {
overflow: hidden;
left: 0;
height:150px;
width: 100%;
background-color: black;
padding: 0px;
margin-left: 0px;
position: absolute;
top: -50px;

}

回答1:

Just remove the top:-50px

and add this

html, body{
margin:0;
padding:0;
}

and your header should start on the top-left corner of the side