简体   繁体   English

HTML:为什么按钮元素总是略微低于其他元素?

[英]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 &nbsp;&nbsp;
                    <a href="">My Garage</a> &nbsp;|&nbsp;
                    <a href="">Account Settings</a>&nbsp;|&nbsp;
                    <a href="">Sign Out</a> &nbsp;|&nbsp;
                    <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.

相关问题 为什么在html上删除doctype会稍微改变屏幕上的某些元素 - Why does removing doctype on html slightly shift some on screen elements 始终将元素放置在页面底部,其他元素下方 - Position an element always at the bottom of the page, below other elements 为什么iOS上具有CSS尺寸(以像素为单位)的HTML元素会显得略大? - Why do HTML elements with CSS sizes measured in pixels appear slightly larger on iOS? 弹出窗口没有出现在按钮下方 - PopUp does not appear below the button 为什么内联块元素出现在内联元素下面? 如何让它们出现在同一条线上? - Why does the inline-block element appear below the inline element? How to make them appear on the same line? 为什么我的按钮始终显示在所有内容之上? - Why does my button always appear above everything? td出现在html表中其他td的下方 - td appear below other td in html table 为什么下拉菜单在其容器元素中未使用overflow:hidden css出现在其容器下方? - Why does dropdown menu not appear below its container using overflow:hidden css in its container element? 为什么 <p> 元素跳出div并显示在下面的下一行中? - Why does <p> element jump out of div and appear in next line below? 为什么在HTML Canvas下方添加小div时会出现水平滚动条? - Why does a horizontal scroll-bar appear when adding small div below HTML Canvas?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM