Input and Div Matching Heights

Viewed 190

I am trying to get the height and width of a Div to match the height and width of an Input field.

Here is the jsfiddle: https://jsfiddle.net/1kv70eg1/

#outerDivOne, #outerDivTwo {
  height: 4em;
  width: 20em;
  border:solid blue 1px;
}
#onTop, #needSameWidth {
  text-align: center;
  border: solid #333333 1px;
  font-size: .9em;
  width: 5em;
  height: 2em;
  border-radius: 3%;
  background-color: whitesmoke;
  vertical-align: center;
}

#onRight, #needSameHeight {
  display:inline-block;
  text-align: center;
  border: solid #333333 1px;
  font-size: .9em;
  width: 5em;
  height: 2em;
  border-radius: 3%;
  background-color: whitesmoke;
  vertical-align: center;
  float: left;
}
<div id='outerDivOne'>
  <input type='text' id='onTop' placeholder='whatever'/>
  <div id="needSameWidth"><output>Test</output></div>
</div>

<div id='outerDivTwo'>
  <input type='text' id='onRight' placeholder='whatever'/>
  <div id="needSameHeight"><output>Test</output></div>
</div>

2 Answers
Related