I developed an index.html page in django project. The below is the template code I developed. Right now, the navigation bar is coming at the bottom
index.html
ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #dddddd
}
li {
display: inline-block;
}
li a {
display: block;
color: #000;
text-align: center;
padding: 20px 24px;
text-decoration: none;
}
li a:hover {
background-color: #555;
color: white;
}
.active {
background-color: #337ab7;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Contact Book Template</title>
<link type="text/css" rel="stylesheet" href="{%static 'css/style.css' %}" />
<!-- Google Font -->
<link href="https://fonts.googleapis.com/css?family=PT+Sans:400" rel="stylesheet">
</head>
<body>
<img class="contact_book" src="{% static 'img/contact_book.jpg' %}" alt="first" />
<div id="booking" class="section">
<div>
<ul id="horizantal-style">
<li><a href="#">Home</a></li>
<li><a href="#">News</a></li>
<li><a href="#">Contact</a></li>
<li style="float:right"><a href="#">Login</a></li>
<li style="float:right"><a class="active" href="#about">Sign up</a></li>
</ul>
</div>
</div>
</body>
</html>
I am expecting it to set the navigation bar at the top, could anyone please help?
2
Answers
You just need to change your HTML markup a little bit. Put the image tag after the menu.
If you want to place an image before the menu it’s also possible to wrap everything in a flex container and change the order of items, but it’s overhead for this task.
I made two examples using some altered markup to not use
ul
andli
items which gives a slight bit of flexibility in the layout so we can then style with independent html blocks in the header to push them each direction usinggrid
cssFirst example shows the provided small set with some ugly borders and padding to show what is where.
The second build on this with a commonly seen addition to a navigation as a header.
Why: Review the second example to see the "header" with content and a footer.
Why not use
li
: here I add some additional markup: