Reputation: 83
i'm trying to get a horizontal navigation bar, but I can't get it to work right.
nav {
text-align: center;
}
nav ul {
margin: 0;
padding: 0;
list-style: none;
display: inline-block;
}
nav ul li {
display: inline;
}
nav ul li a {
text-decoration: none;
display: block;
width: 80px;
}
Upvotes: 0
Views: 1553
Reputation: 435
You need float:right
on nav ul li
visit link
nav ul li {
float:left;
display: inline;
}
Upvotes: 0
Reputation: 1812
Or you could try using inline-block instead of block
nav ul{
display: block;
overflow: hidden;
margin: 0 auto;
}
nav ul li{
display: inline-block;
}
Upvotes: 0
Reputation: 1870
Simple solution:
Set 'float:left' for the list element and also do 'display:inline-block'
nav ul li{
float:left;
display:inline-block;
}
Let me know if it worked. I have had the same problem recently. I can help you out more.
Upvotes: 0
Reputation: 15609
Set your li
to inline-block
rather than inline
.
nav ul li {
display: inline-block;
}
Upvotes: 3