Input Groups

by Craig Haywood

HTML

<div class="input-group">
  <input class="input-field" type="text">
  <span class="input-group-btn">
    <button class="btn" type="button">Update</button>
  </span>
  
</div>
<div class="input-group">
  <span class="input-group-btn">
    <button class="btn" type="button">Update</button>
  </span>
  <span class="input-group-btn">
    <button class="btn" type="button" disabled>Cancel</button>
  </span>
<input class="input-field" type="text">
</div>

<div class="input-group">
  <span class="input-group-btn">
    <button class="btn" type="button">Update</button>
  </span>
<input class="input-field" type="text">
  <span class="input-group-btn">
    <button class="btn" type="button" disabled>Cancel</button>
  </span>
</div>

CSS

html {
  font-size: 10px;
}

body {
  padding: 2em;
}

.input-field {
  border: none;
  height: 4rem;
  border-radius: 3px;
  font-size: 1.5rem;
  box-sizing: border-box;
  
  background: #555;
  color: #fff;
}

.btn {
  border-color: transparent;
  background: #6f5499;
  color: #fff;
  height: 4rem;
  line-height: 4rem;
  display: inline-block;
  vertical-align: top;
  padding: 0 1rem;
  -webkit-appearance: none;
  appearance: none;
  border-radius: 3px;
}

.btn:disabled {
    cursor: not-allowed;
    pointer-events: none;
    opacity: .6;
}

.btn:hover {
  background: #000;
}


.input-group {
  position: relative;
  display: table;
  border-collapse: separate;
  box-sizing: border-box;
  
  margin-bottom: 3rem;
}

.input-group .input-field {
  display: table-cell;
  width: 100%;
  position: relative;
  float: left;
  z-index: 2;
}

.input-group-btn {
    position: relative;
    white-space: nowrap;
    width: 1%;
    vertical-align: middle;
}

.input-group-btn {
  display: table-cell;
}

.input-group .input-field:not(:last-child),
.input-group-btn:not(:last-child) .btn {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

.input-group .input-field:not(:first-child),
.input-group-btn:not(:first-child) .btn {
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}