Forum Moderators: not2easy

Message Too Old, No Replies

Position Image next to text input

         

Crump

7:45 am on Jan 22, 2011 (gmt 0)

10+ Year Member



I am trying to get an image next to a text input. The problem is the text input is centered in a div. The image only appears at certain times (via javascript). When it does, the stuff shifts around trying to maintain center.

However, what I want is the input text to remain in the exact same spot, and the image to just come up in the space next to it. So the text input is still centered, but the image is not.

The solution I have now is to add a blank GIF (same dimensions as the other image) to the other side to even it out, but there has to be better way with css?

Thanks

SuzyUK

10:32 am on Jan 22, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



absolutely position the image

example using a span instead of image:

body {text-align: center;}
span {position: absolute; margin-top: 2px; width: 20px; height: 20px; background: red;}

<input type="text" value="centered"><span></span><br>
<input type="text" value="centered">


AP takes the element out of the flow, so will not affect the page/input alignment