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.但我確實使用樣式= “垂直對齊:中間”的工作就像一個魅力。