Search code examples
htmlcssvertical-alignment

How can I make the text of my button been perfectly aligned vertically?


Good day,

I have two buttons with an up and down arrow, as shown in my picture below.

enter image description here

The corresponding html code is the following :

[...]

<tr>
  <td class="tablerows" height="40">lab01 - Temp&#233;rat. pi&#232;ce [T1]</td>
  <td class="tablerows"><input id="lab01" type="text" name="country" class="resizedTextbox" value="20" readonly>
    <a href="#" class="myButton" onclick="TemperatureControl('lab01','decrease')"><i class="fa fa-chevron-down"></i></a>
    <a href="#" class="myButton" onclick="TemperatureControl('lab01','increase')"><i class="fa fa-chevron-up"></i></a>
</td>
</tr>

[...]

Edit, thanks to your help. However, I am still not able to align all my elements, as I would like

The linked CSS is the following :

td{
  vertical-align:middle;
}
.myButton {
    -moz-box-shadow:inset 0px 1px 0px 0px #54a3f7;
    -webkit-box-shadow:inset 0px 1px 0px 0px #54a3f7;
    box-shadow:inset 0px 1px 0px 0px #54a3f7;
    background-color:#3e12cc;
    -moz-border-radius:3px;
    -webkit-border-radius:3px;
    border-radius:3px;

    display:inline-block;
    cursor:pointer;
    color:#ffffff;
    font-family:Arial;
    font-size:18px;
    padding: 0 10px 10px 10px;
    text-decoration:none;
    text-shadow:0px 1px 0px #154682;
    width:20px;
    height:25px;
    vertical-align:-1px;
    line-height:auto;
}
.myButton:hover {
    background-color:#0061a7;
}
.myButton:active {
    position:relative;
    top:1px;
}
.resizedTextbox {width: 50px; 
height: 20px;
padding: 5px 5px 5px 5px;
border-color:#3e12cc;
text-shadow:0px 1px 1px #154682;
background-color:#f5effb;
vertical-align:text-top;
text-align:center;
font-size:18px;
}
progress {
  background-color: #0061a7;
  border: 0;
  height: 18px;
  border-radius: 9px;
}

What I am basically trying to do is to have a 'good' vertical alignment (in my example, we can see that it's not very well aligned).

Before annoying you - and risking a negative downvote - I tried to google my problem, but I could not find the issue that I am having. Am I missing a property or did I set it incorrectly ?

Thanks for your hints


Solution

  • I was able to align it with

    vertical-align:-6px;
    

    Try this it should work. Please share a codepen going forward, so that its easier for others