Mcloving
Mcloving

Reputation: 1410

CSS Center link and fill bar to end of page

I am trying to vertically align the text inside my nav bar.

Ive tried using vertical-align. But its not working.

Ive also made sure its got height to actually align inside.

Also, is there a way to fill the nav bar to the end of the page, a parallogram/rectangle. So that there is no white space on right of the links. So it is effectively one long bar, split by parallograms.

http://jsfiddle.net/Z4kUm/

 <ul id="navlist">
                        <li><a><span>Link</span></a></li>
                        <li><a><span>Link</span></a></li>
                        <li><a><span>Link</span></a></li>
                         <li><a><span>Link</span></a></li>
                    </ul>

My css:

ul#navlist {
    padding:10px;
    font: bold 12px Arial, sans-serif;
   display: inline;
}

ul#navlist li {
    float:left;
    margin-right:20px;
    display:inline-block;
    zoom:1;
    position:relative;
    width:125px;
    height: 50px;
    list-style: none;
    color:#757575;
}

ul#navlist li a {
    display: inline-block;
    vertical-align: middle;
    text-decoration:none;
    padding:5px 10px;
    transform: skewX(-20deg);
    -o-transform: skewX(-20deg);
    -moz-transform: skewX(-20deg);
    -webkit-transform: skewX(-20deg);
     width:115px;
     height: 40px;

}

ul#navlist li a span 
{
    width: 100%;
    height: 40px; 
    display: inline-block;
    text-align: center;
    vertical-align: middle;
    transform: skewX(20deg);
    -o-transform: skewX(20deg);
    -moz-transform: skewX(20deg);
    -webkit-transform: skewX(20deg);
}

ul#navlist li a {
    background:#AAA;
}

Upvotes: 0

Views: 86

Answers (1)

j08691
j08691

Reputation: 207913

Set the line-height property on the spans to match their height.

jsFiddle example

ul#navlist li a span 
{
    width: 100%;
    height: 40px; 
    line-height:40px;
    display: inline-block;
    text-align: center;
    vertical-align: middle;
    transform: skewX(20deg);
    -o-transform: skewX(20deg);
    -moz-transform: skewX(20deg);
    -webkit-transform: skewX(20deg);
}

Upvotes: 1

Related Questions