0

Using HTML/CSS I want to create button-like link:

a.btnlink{
    border: 2px solid #808080;
    -webkit-box-align: center;
    -moz-box-align: center;
    box-align: center;
    display: -webkit-box;
    display: -moz-box;
    display: box;
    height: 50px;
    margin-bottom: 5px;
    padding: 2px;
    text-align: center;
    text-decoration: none;
    width: 200px;
}

This works fine with one exception: The text within the button box is not centered horizontally (only vertically).

How can I center the text within the box?
And: is my approach to create a button-like link correct, or can I achive that easier?

Kevin Boucher
  • 16,426
  • 3
  • 48
  • 55
Matthias
  • 9,817
  • 14
  • 66
  • 125

2 Answers2

2

Try this instead:

a.btnlink
{
    border: 2px solid #808080;
    display: inline-block;
    height: 54px;            /* height & line-height values match */
    line-height: 54px;       /* causing vertical centering (for one-line string) */
    margin-bottom: 5px;
    width: 204px;
    text-align: center;      /* centers horizontally */
    text-decoration: none;
}
Kevin Boucher
  • 16,426
  • 3
  • 48
  • 55
2

Like Kevin mentioned, display: inline-block could have been the key...

Gary Klasen
  • 1,001
  • 1
  • 12
  • 30