简体   繁体   中英

How do i put my Navigation Bar on the left

I'm having trouble with putting my navigation bar on the left side of my simple webpage. It must be below the header section. This is the Whole HTML Code.

<html>
<head>
<title>My Homepage</title>
</head>
<style>
#header{
width:800px;
height:200px;
background-color:yellow;
}
#footer{
width:800px;
height:100px;
background-color:red;
clear:both;
}
#nav{
width:200px;
height:400px;
background-color:pink;
float:left;
}
#con{
width:800px;
height:400px;
background-color:gray;
}
</style>
<body>

<div id=external>
<div id=header><b>SAMPLE HEADER<b> <img src="kappa.gif"alt="kappa"height="50"width="50"></div>
<div id=con><iframe name=container width=100% height=100% src=default.html></iframe></div>
<div id=footer><b>PUP COPYRIGHT 2016<b> <img src="pup.jpg"alt="pup"height="50"width="50"></div>
<div id=nav>
<ul>
  <li><a href=AboutUs.html target=container>About Us</a></li>
  <li><a href=ContactUs.html target=container>Contact Us</a></li>
</ul>
</div>

I'm having trouble with putting my navigation bar on the left side of my simple webpage. It must be below the header section.

Your CSS will actually work perfectly if you move your nav markup up to be directly below your closing header div:

<div id=external>
<div id=header><b>SAMPLE HEADER<b> <img src="kappa.gif"alt="kappa"height="50"width="50"></div>
<div id=nav>
<ul>
  <li><a href=AboutUs.html target=container>About Us</a></li>
  <li><a href=ContactUs.html target=container>Contact Us</a></li>
</ul>
</div>
<div id=con><iframe name=container width=100% height=100% src=default.html></iframe></div>
<div id=footer><b>PUP COPYRIGHT 2016<b> <img src="pup.jpg"alt="pup"height="50"width="50"></div>

Please refer the code to make it

#nav {
    width: 100%;
    height: auto;
    background-color: pink;
    float: left;
}

<div id=external>
    <div id=header><b>SAMPLE HEADER<b> <img src="kappa.gif"alt="kappa"height="50"width="50">
        <div id=nav>
            <ul>
                <li><a href=AboutUs.html target=container>About Us</a></li>
                <li><a href=ContactUs.html target=container>Contact Us</a></li>
            </ul>
        </div>
    </div>

    <div id=con><iframe name=container width=100% height=100% src=default.html></iframe></div>
    <div id=footer><b>PUP COPYRIGHT 2016<b> <img src="pup.jpg" alt="pup" height="50" width="50"></div>
</div>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM