Reputation: 6735
i have a navigation bar and i am positioning it absolute, i have a problem with the padding on it, the top and bottom padding are not taking effect on the anchor tag, only the left and right, any idea why this might be occurring?
<nav class="main-nav">
<ul class="main-nav-links">
<li class="main-link"><a href="#">HOME</a></li>
<li class="main-link"><a href="#">ABOUT US</a></li>
<li class="main-link"><a href="#">ORDER</a></li>
<li class="main-link"><a href="#">CONTACT</a></li>
</ul>
</nav>
Here is the css for the nav:
.main-nav {
position: absolute;
bottom: 0;
margin-left: 290px;
}
.main-link {
list-style: none;
background-color: #1281f4;
display: block;
float: left;
}
.main-link > a {
text-decoration: none;
color: #073a4f;
padding: 1em;
}
Upvotes: 1
Views: 77
Reputation: 8981
try this
CSS
.main-nav {
position: absolute;
bottom: 0;
margin-left: 290px;
}
.main-link {
list-style: none;
background-color: #1281f4;
display: block;
float: left;
}
.main-link > a {
text-decoration: none;
color: #073a4f;
padding: 1em;
display: inline-block;
}
Upvotes: 0
Reputation: 18861
Add display: inline-block;
to the <a>
.
The way it is, it is rendered as a piece of text, and as such, it can't have vertical padding.
An alternative would be to use line-height
;
Here's a demo: fiddle.
Upvotes: 4