<h1>Search Box With Variable Width Button</h1>
<p>This search box is actually always 400px wide, but try changing the text in the button - the button will resize and the input will pick up the slack. Sweet.</p>

<div id='container'>  
  <div class='cell'><input type='search' placeholder='Search'></div>
  <div class='cell'><div class='button'>Give'r</div></div>
</div>
body {
  background-color: #41B3FF;

  font-family: 'helvetica', 'verdana', sans-serif;
  font-size: 16px;
  padding-top: 40px;
}
h1, p {
  text-align: center;
  color: #fff;
  margin: 0 auto;
  max-width: 700px;
}

/* ----------- Relevant Code Below ----- */

div#container {
  display: table;
  
  /* I want the whole search box
     to be exactly this wide. */
  width: 400px;
  
  margin: 50px auto 0;
}
div#container div.cell {
  display: table-cell;
}
div#container div.cell:last-child {
  /* Makes sure this cell is only wide enough
     for the button label. */
  width: 1px;
}

input[type=search], div.button {  
  width: 100%;
  height: 35px;

  -moz-box-sizing: border-box;
  box-sizing: border-box;
  
  font-family: inherit;
  font-size: inherit;
}

input[type=search] {
  margin: 0;
  padding: 0 10px;
  
  background-color: #f8f8f8;
  
  border: 0;
  border-top-left-radius: 5px;
  border-bottom-left-radius: 5px;
}

div.button {
  line-height: 35px;

  margin: 0;
  padding: 0 20px;

  color: #fff;
  background-color: #FF1717;
  font-weight: bold;
  
  border-top-right-radius: 5px;
  border-bottom-right-radius: 5px;
  
  white-space: nowrap;
}
Run Pen

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.