Reputation: 25
I was trying to make the nav bar all in the same line but the last block in the nav bar didnt work html:
<div id="navbar"><ul>
<li>Home</li>
<li id="title">Welcome to this website</li>
<li>Sign up to get update to your inbox:<input type="text" placeholder="Type in your email adress"></input><input type="submit" value="submit"></intput></li>
</ul></div>
css:
#navbar li{
display:block;
float:left;
font-size:25px;;
height:30px;
background-color:#D2A7F2;
padding:20px;
text-align:center;
width:33%;
border-right:2px solid #FF2508;
border-bottom:2px solid #FF2508;
}
#navbar ul{
list-style-type:none;
}
#navbar{
overflow:hidden;
margin-left:-40px;
}
Upvotes: 1
Views: 74
Reputation: 279
Add box sizing to include the padding and increase the width to equal (closer to) 100%.
#navbar li {
box-sizing: border-box;
width: 33.33%
}
Upvotes: 0
Reputation: 15951
adding box-sizing: border-box;
will fix the issue you have given padding which increases the width
by adding box-sizing: border-box;
the padding
is given from inside
also set ul
width
to 100%
if you want to take make it full screen and li
should be 33.33%
remove the left
-ve margin
for you #navbar
and add margin:0
because it will remove default margin
given by browser
Upvotes: 1