Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Mikey Neilson
Front End Web Development Techdegree Student 12,642 PointsHelp with navbar
Hi treehouse community i'm trying to make a navbar but i seem to be going wrong with the links in it can anyone shed an light on this for me, I am a newbie to this so not sure if what iv done is on the right lines ,i'm sure that i will be told if its totally wrong :) here is my code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Vaping Bean</title>
<link rel="stylesheet" href="normalize.css">
<link href='https://fonts.googleapis.com/css?family=Nosifer|Creepster|Kalam' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="main.css">
</head>
<body>
<div class="container">
<header class="navbar">
<ul>
<li><h1 class="name">Vaping Bean</h1></li>
<li><a href="#">Home</a></li>
<li><a href="#">Starter Kits</a></li>
<li><a href="#">Atomizers</a></li>
<li><a href="#">E-liquid</a></li>
<li><a href="#">Contact</a></li>
</ul>
</header>
</div>
</body>
</html>```
```css
body {
margin: 0;
font-size: 1.5em;
}
.name {
margin: 10px 20px;
padding: 0 20px 0 5px;
background-color: green;
font-size: 2em;
font-family: 'Nosifer', sans-serif;
text-shadow: 5px 10px 10px #fff;
border-radius: 5px;
}
.navbar ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #333;
}
.navbar li {
float: left;
border-right: 1px solid #fff;
}
.navbar li a {
display: block;
text-align: right;
color: white;
padding: 14px 16px;
text-decoration: none;
font-size: 1em;
} ```
1 Answer
Fynn Lehnert
15,244 Pointstry setting you li to display: inline-block.
li'st items are by default block items, meaning that they will take all the available width of their parent element. setting them to inline-block changes that, so they only take on their content width.
.navbar li {
display: inline-block;
border-right: 1px solid #fff;
}