Reputation: 61
I am trying to get my unordered list elements to be sitting side-by-side next to each other on a navigation menu bar.
Problems:
Following is my attempt, can anyone spot where I've gone wrong? Much appreciated.
HTML:
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div class="nav">
<h1 class="logo">LogoHere</h1>
<ul class="nav-menu">
<li>Action</li>
<li>Who we are?</li>
<li>Blog</li>
<li>Services</li>
<li>Get in touch</li>
</ul>
</div>
</body>
</html>
CSS:
.nav{
background-color: #2EC0FE;
opacity: 0.75;
-moz-box-shadow: 0px 0px 0px rgba(0,0,0,1), inset 0px 0px 0px rgba(0,0,0,1);
-webkit-box-shadow: 0px 0px 0px rgba(0,0,0,1), inset 0px 0px 0px rgba(0,0,0,1);
box-shadow: 0px 0px 0px rgba(0,0,0,1), inset 0px 0px 0px rgba(0,0,0,1);
background-image: -o-linear-gradient(90deg , rgb(0,0,0) 0%, rgb(0,0,0) 100%);
background-image: -moz-linear-gradient(90deg , rgb(0,0,0) 0%, rgb(0,0,0) 100%);
background-image: -webkit-linear-gradient(90deg , rgb(0,0,0) 0%, rgb(0,0,0) 100%);
background-image: -ms-linear-gradient(90deg , rgb(0,0,0) 0%, rgb(0,0,0) 100%);
background-image: linear-gradient(90deg , rgb(0,0,0) 0%, rgb(0,0,0) 100%);
height: 100px;
width: 100%;
margin-top: 600px;
}
.logo{
font-family: times, Times New Roman, times-roman, georgia, serif;
font-size: 54px;
line-height: 40px;
letter-spacing: -5px;
color: white;
margin: 0 0 0 0;
padding-top: 25px;
padding-left: 25px;
font-weight: 100;
}
.nav-menu
{
list-style-type: none;
display: inline;
text-align: center;
font-size: 20px;
color: white;
padding: 0px;
margin-top: 0px;
}
Image problem 3: This is when the window is not full screened and this is just the way I want my nav bar to be positioned
Following is when it is full screened and you can see the background image has expanded and now the nav bar position is much higher then how I want it to be in the first image.
Upvotes: 0
Views: 17065
Reputation: 89750
First Item:
display: inline;
to .nav-menu li
instead of .nav-menu
.h1
(and so are other heading tags) is by default a block
element. To display it in same line as the menu, add display: inline-block;
to logo
.Second Item:
body
by default has margins. Hence to make the nav
bar take the entire space, you have to add body {margin: 0;}
to the CSS.Third Item:
position: absolute; bottom: 0px;
to the .nav
class. This will put the bar at the bottom.Working Demo covering all three above items.
Upvotes: 2