Good day,
I have two buttons with an up and down arrow, as shown in my picture below.
The corresponding html code is the following :
[...]
<tr>
<td class="tablerows" height="40">lab01 - Températ. piè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
Use this css, removed height and width and added box-sizing
box-sizing: border-box;
padding:10px;
.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; text-decoration: none; text-shadow: 0px 1px 0px #154682; box-sizing: border-box; padding: 10px; }
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" /> <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>
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
为.myButton
添加行高
line-height:25px;
You need vertical-align:middle
. Try it and tell me if works, otherwise, you can add padding-top:
for separete it from top.
Thanks all for your very quick replies. The solution provided by Gowtham Shiva helped me a lot, although many other ones that I upvoted are perfect.
Finally, here is the contents of my css file :
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: 5px 10px 5px 10px;
text-decoration:none;
text-shadow:0px 1px 0px #154682;
width:20px;
height:25px;
vertical-align:-6px;
}
.myButton:hover {
background-color:#0061a7;
}
.myButton:active {
position:relative;
top:1px;
}
.resizedTextbox {width: 40px;
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;
}
Hope this post will help someone in a similar situation.
Have a good week-end.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.