[英]HTML : Why does a button element always appear slightly below the other elements?
I have noticed that the <button>
element in HTML always appears slightly lower than other elements as shown in the figure below. 我注意到HTML中的
<button>
元素总是略低于其他元素,如下图所示。
As you can see, the "Go" button is slightly lower than the textarea element which on the same row as it is. 如您所见,“Go”按钮略低于同一行上的textarea元素。 The code for this is as follows...
这个代码如下......
<table width="100%">
<tr>
<th rowspan="2" align="left">
<img width="120px" height="60px" src="test-image.jpg" />
</th>
<th align="right">
User
<a href="">My Garage</a> |
<a href="">Account Settings</a> |
<a href="">Sign Out</a> |
<br/>
<textarea rows="1" id="search_text"></textarea><button>Go!</button>
</th>
</tr>
</table>
Why does this happen and what is the easiest fix for this ? 为什么会发生这种情况,最简单的解决办法是什么?
Try applying vertical-align: text-bottom;
尝试应用
vertical-align: text-bottom;
to your button. 到你的按钮。
You should be using an input
tag, not a textarea
for a single row. 您应该使用
input
标记,而不是单行的textarea
。 Try this code: 试试这段代码:
<input type="text" id="search_text"><button>Go!</button>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.