Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here is a simple and clean solution without using JavaScript or table layout hacks. It is similar to this answer: <a href="https://stackoverflow.com/questions/10244927/input-text-auto-width-filling-100-with-other-elements-floating">Input text auto width filling 100% with other elements floating</a></p> <p>It is important to wrap the input field with a span which is <code>display:block</code>. Next thing is that the button has to come first and the the input field second.</p> <p>Then you can float the button to the right and the input field fills the remaining space.</p> <p>HTML</p> <pre><code>&lt;form method="post"&gt; &lt;button&gt;Search&lt;/button&gt; &lt;span&gt;&lt;input type="text" title="Search" /&gt;&lt;/span&gt; &lt;/form&gt; </code></pre> <p>CSS</p> <pre><code>form { width: 500px; overflow: hidden; background-color: yellow; } input { width: 100%; } span { display: block; overflow: hidden; padding-right:10px; } button { float: right; } </code></pre> <p>A simple fiddle: <a href="http://jsfiddle.net/v7YTT/90/" rel="noreferrer">http://jsfiddle.net/v7YTT/90/</a></p> <p><strong>Update 1:</strong> If your website is targeted towards modern browsers only, I suggest using <a href="https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Flexible_boxes" rel="noreferrer">flexible boxes</a>. Here you can see <a href="http://caniuse.com/flexbox" rel="noreferrer">the current support</a>.</p> <p><strong>Update 2:</strong> This even works with multiple buttons or other elements that share the full with with the input field. Here is <a href="http://jsfiddle.net/v7YTT/1439/" rel="noreferrer">an example</a>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload