Reputation: 65254
<div class="navigation">
<a class="active" href="index.html">1</a>
<a href="index.html">2</a>
<a href="index.html">3</a>
<a href="index.html">4</a>
</div>
.navigation {
float: left;
height: 160px;
position: relative;
width: 24px;
}
.navigation a {
display: block;
}
Can anyone help me how to make <a>
vertically center inside <div class="navigation">
. Number of <a>
s ranges so I can't just do padding-top
on <div class="navigation">
.
Please help. Thanks.
Upvotes: 1
Views: 89
Reputation: 51431
In any case. If you wanted it VERTICALLY
and HORIZONTALLY
aligned (in all browsers including IE6, maybe no IE5.5 MAC):
.navigation {
float: left;
height: 160px;
position: relative;
width: 24px;
text-align: center;
display: table;
_position: relative;
overflow: hidden;
}
.navigation_inner {
_position: absolute;
_top: 50%;
display: table-cell;
vertical-align: middle;
}
.navigation a {
display: block;
}
HTML
<div class="navigation">
<div class="navigation_inner">
<a class="active" href="index.html">1</a>
<a href="index.html">2</a>
<a href="index.html">3</a>
<a href="index.html">4</a>
</div>
</div>
Upvotes: 2
Reputation: 21388
text-align: center
.navigation {
float: left;
height: 160px;
position: relative;
width: 24px;
text-align: center;
}
.navigation a {
display: block;
}
EDIT If you want it to be vertically centered as well you will need to add another bounding box to be vertically centered:
<style type='text/css'>
.navigation {
float: left;
height: 160px;
position: relative;
width: 24px;
border: 3px solid black;
text-align: center;
display: table;
}
.wrapper {
vertical-align: middle;
display: table-cell;
}
.navigation a {
display: block;
}
</style>
<div class="navigation">
<div class='wrapper'>
<a class="active" href="index.html">1</a>
<a href="index.html">2</a>
<a href="index.html">3</a>
<a href="index.html">4</a>
</div>
</div>
Upvotes: 2
Reputation: 5102
Try this
.navigation {
float: left;
height: 160px;
position: relative;
width: 24px;
vertical-align: middle;
}
.navigation a {
display: block;
}
Upvotes: 1