How To Perfectly Align Image Button With HTML Input Textbox Come allineare perfettamente l'immagine pulsante con testo HTML di input
The form element input with type text strangely refuses to align with an adjacent image button ( input element of type image ). Sotto forma elemento di input di tipo testo stranamente si rifiuta di allinearsi con uno adiacente immagine pulsante (elemento di input di tipo immagine). 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. Il problema è piuttosto difficile da risolvere come regolare utilizzando metodi come allineare o margine o imbottitura o anche l'aggiunta di spazi per l'immagine non riesce. Here is a surprisingly simple solution to this problem. Qui è un sorprendentemente semplice soluzione a questo problema. But first lets take a look at the problem. Ma prima consente di dare un'occhiata alle problema.
The input textbox above is misaligned with the image button above as you can see. L'input di testo di cui sopra è fuori allineamento con l'immagine sopra il pulsante come si può vedere. The code is: Il codice è:
The solution is deceptively simple. La soluzione è ingannevolmente semplice. Here is the code which works: Qui è il codice che funziona:
Here is the demo: Ecco la demo:
Filed under Elencato sotto Headline News Headline News , How To Come , Tech Note Nota tech , Web | |
| |
RSS 2.0 RSS 2,0 | |
Trackback this Article | questo articolo |
Email this Article Invia questo articolo
You may also like to read Si può anche leggere come |





July 19th, 2006 at 10:02 pm 19 luglio 2006 a 10:02 pm
what about aligning them both at the middle vertically? per quanto riguarda l'allineamento entrambi a metà in verticale?
July 27th, 2006 at 11:44 pm 27 luglio 2006 a 11:44 pm
align=absmiddle is deprecated. align = absmiddle è deprecato.
Can anyone explain why this behaviour happens, and why position: absolute solves it? Chiunque può spiegare perché questo comportamento si verifica, e perché posizione: assoluta risolve?
I’m constantly coming across CSS problems but the solutions don’t leave me any the wiser Sono costantemente in tutta provenienti CSS problemi, ma le soluzioni non mi lasciare qualsiasi il saggio
August 8th, 2006 at 12:07 pm Agosto 8th, 2006 a 12:07 pm
Kat: This is probably due to the “image baseline” issue, where there is whitespace at the bottom of an image. Kat: Ciò è dovuto probabilmente a "immagine di base" problema, dove c'è spazio bianco nella parte inferiore di un'immagine. Since images are inline objects, they sit on the baseline and not at the bottom of the containing block. Dal momento che le immagini sono in linea di oggetti, che fanno parte della base e non in fondo contenente il blocco. Changing the style to “display: block;” would also work in an example like this. Cambiare lo stile di "display: block;" anche operare in un esempio come questo.
November 21st, 2006 at 4:20 pm 21 novembre 2006 alle 4:20 pm
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. Ho cercato questo ive figurato e che la messa ur elementi in una tabella, ciascuna in un différent cella sta facendo l'allineamento molto bene.
Cause playing wit absolute positioning in a table can end up really messy. Causa giocando con il posizionamento assoluto in una tabella può finire veramente disordinati.
( normal textbox is setting height and text size from my CSS style sheet ) (Testo normale è l'impostazione altezza e la dimensione del testo dal mio foglio di stile CSS)
January 5th, 2007 at 9:38 pm 5 gennaio 2007 a 9:38 pm
using vertical-align: text-bottom is the best way to achieve the desired effect utilizzando verticale-align: text-bottom è il modo migliore per raggiungere l'effetto desiderato
February 1st, 2007 at 9:25 am 1 ° febbraio 2007 a 9:25 am
Bonjour,
Sous IE6, le bouton Go est 1 pixel au-dessus du input Sous IE6, le bouton Go è 1 pixel au-dessus du input
Tout le monde le voit Tout le monde Le Voit
June 28th, 2007 at 12:43 am 28 giugno 2007 alle 12:43 am
Fantastic - I’ve used this to align PayPal shopping cart buttons so they don’t affect the page layout below them. Fantastic - Ho usato questo per allineare Carrello PayPal pulsanti in modo da non incidere il layout di pagina sotto di loro. It’sa problem with PayPal that has been bugging me for ages! È un problema che con PayPal è stato bugging me per età! Thanks. Grazie.
November 19th, 2007 at 2:05 am 19 Novembre 2007 alle 2:05 am
Bonjour, you can solve the 1 pixel problem easily. Bonjour, è possibile risolvere il problema 1 pixel facilmente.
Complete Code: Completo Codice:
November 19th, 2007 at 2:10 am 19 Novembre 2007 alle 2:10 am
asp:ImageButton ID=\ asp: ImageButton ID = \
May 7th, 2008 at 6:55 am 7 maggio 2008, 6:55 am
Works a charm! Opere di un fascino!
May 16th, 2008 at 11:08 pm 16 maggio 2008, 11:08 pm
This has been a booger… Questa è stata una booger…
Didn’t work for me. Non ha funzionato per me.
But I did use style=”vertical-align: middle” which worked like a charm. Ma ho fatto uso style = "vertical-align: metà", che ha lavorato come un fascino.