user2834739
user2834739

Reputation: 3

CSS padding in the li>a elements

I want to align the fonts so that they appear at center while not increasing the maximum height of #nav li a above 60px. Please suggest a way. max-height didn't work in this case.

HTML

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <link href="StyleSheet.css" rel="stylesheet" type="text/css" />
</head>
<body>
    <div>
        <ul id="nav">
            <li><a href="#">Work</a></li>
            <li><a href="#">Blog</a></li>
            <li><a href="#">About</a></li>
            <li><a href="#">Contact</a></li>
        </ul>
    </div>
</body>
</html>

CSS

#nav {
list-style-type: none;
margin: 0;
padding: 0;
}
#nav li {
width: 20%;
float: right;
text-align:center;
}
#nav li a {
height:60px;
display: block;
padding: 0.5em 5px 0.5em 5px;
text-decoration: none;
font-weight: bold;
color: #F2F2F2;
}
#nav a:link, #nav a:visited {
background-color: #071726;
}
#nav a:hover, #nav a:active, #nav a:focus {
background-color: #326773;
}

Upvotes: 0

Views: 100

Answers (2)

Eugine Joseph
Eugine Joseph

Reputation: 1558

Add line-height:60px to #nav li a.

Here is the fiddle.

Upvotes: 3

Rahul
Rahul

Reputation: 842

Added a line-height attribute to the nav links in your CSS. Check it out: http://jsfiddle.net/2xEz2/

Upvotes: 0

Related Questions