-1

I want to do the following

(we are inside a fix width div)
<input text><img>

if I set 100% width to the text, the img goes newline.

EDIT: I tried:

<div style="width: auto;">
<input style="width: 100%; float: left;" />
</div>
<img style="float: right;" alt="smiles" src="a.gif" width="21" height="21" />
user1929946
  • 2,453
  • 2
  • 15
  • 17

1 Answers1

1

Try this code:

<div>
    <img style="float:right;" src="a.gif" />
    <input style="width: 100%; display:block;" />
</div>

What this code does: It floats the image to the right of the block in question. The display:block; makes the input a block element, which will pay attention to the float above (an inline-element would not care about it).

BTW, I took this solution from here: Expand a div to take the remaining width

Community
  • 1
  • 1
Refugnic Eternium
  • 4,089
  • 1
  • 15
  • 24