How To Perfectly Align Image Button With HTML Input Textbox如何完全统一的形象,按钮的HTML输入文本框
The form element input with type text strangely refuses to align with an adjacent image button ( input element of type image ).形式要素的投入与键入文本奇怪的拒绝,以配合相邻的图像按钮( 投入要素类型的形象 ) 。 The problem is rather hard to solve as regular methods like using align or margin or padding or even adding whitespace to the image fails.问题是相当难以解决,作为经常使用的方法一样,赞同或保证金或填充,甚至加入到空白的形象失败。 Here is a surprisingly simple solution to this problem.这里是一个出乎意料的简单,要解决这个问题。 But first lets take a look at the problem.但首先让考虑一下这个问题。
The input textbox above is misaligned with the image button above as you can see.输入文本框以上是失调与形象上面的按钮,因为你可以看到。 The code is:该代码是:
The solution is deceptively simple.解决的办法是简单。 Here is the code which works:这里是代码,其中工程:
Here is the demo:这里是演示:
Filed under提起下 Headline News头条新闻 , , How To如何 , , Tech Note技术说明 , , Web网页 | |
| |
RSS 2.0 2.0 | |
Trackback Trackback跟踪 this Article |此文章|
Email this Article电子邮件此文章
You may also like to read您也可以想读 |




July 19th, 2006 at 10:02 pm 2006年7月19日在下午10时02分
what about aligning them both at the middle vertically?什么使他们无论是在中东垂直?
July 27th, 2006 at 11:44 pm 2006年7月27日在下午11时44分
align=absmiddle is deprecated.对齐= absmiddle是废弃了。
Can anyone explain why this behaviour happens, and why position: absolute solves it?任何人都可以解释为什么这种行为的发生,以及为什么立场:绝对解决它?
I’m constantly coming across CSS problems but the solutions don’t leave me any the wiser不断地让我感到未来全国的CSS问题,但解决办法不留下我任何有关明智
August 8th, 2006 at 12:07 pm 2006年8月8日在下午12时07分
Kat: This is probably due to the “image baseline” issue, where there is whitespace at the bottom of an image.吉:这可能是由于“形象基线”的问题,那里是空白,在底部的一个形象。 Since images are inline objects, they sit on the baseline and not at the bottom of the containing block.由于图像内嵌的对象,他们坐于基线,而不是在底部的载有座。 Changing the style to “display: block;” would also work in an example like this.转变作风,以“显示:座; ”也将工作在一个例子,像这样。
November 21st, 2006 at 4:20 pm 2006年11月21日在下午4时20分
Ive been trying this and ive figured out that puting ur elements in a table, each in a différent cell is doing the alignment very well.香港专业教育学院一直在努力,这和香港专业教育学院揣摩,把乌拉圭回合的要素在一个表中,每在一个différent细胞是这样做的路线很清楚的。
Cause playing wit absolute positioning in a table can end up really messy.事业发挥智慧绝对定位在一个表中可以结束了真的一塌糊涂。
( normal textbox is setting height and text size from my CSS style sheet ) (正常的文本框是设置高度和文字大小,从我的CSS样式表)
January 5th, 2007 at 9:38 pm 2007年1月5日在下午9点38分
using vertical-align: text-bottom is the best way to achieve the desired effect使用垂直对齐:文本底部是最好的方式,以达到预期的效果
February 1st, 2007 at 9:25 am 2007年2月1日在上午09时25分
Bonjour, bonjour ,
Sous IE6, le bouton Go est 1 pixel au-dessus du input sous的IE6 ,乐布顿去预测1像素太子港dessus杜投入
Tout le monde le voit兜售世界报乐voit
June 28th, 2007 at 12:43 am 2007年6月28日在上午12时43分
Fantastic - I’ve used this to align PayPal shopping cart buttons so they don’t affect the page layout below them.神奇-我已经用这使贝宝购物车的按钮,使它们不影响页面布局下面。 It’sa problem with PayPal that has been bugging me for ages!这是问题,贝宝已窃听我的年龄! Thanks.谢谢。
November 19th, 2007 at 2:05 am 2007年11月19日在上午02时05分
Bonjour, you can solve the 1 pixel problem easily. bonjour ,您就可以解决一像素的问题很容易。
Complete Code:完整代码:
November 19th, 2007 at 2:10 am 2007年11月19日在上午02时10分
asp:ImageButton ID=\ ASP的: imagebutton编号= \
May 7th, 2008 at 6:55 am 2008年5月7日在上午06时55分
Works a charm!工程的魅力!
May 16th, 2008 at 11:08 pm 2008年5月16日在下午11时08分
This has been a booger…这一直是booger …
Didn’t work for me.没有工作的我。
But I did use style=”vertical-align: middle” which worked like a charm.但我确实使用样式= “垂直对齐:中间”的工作就像一个魅力。