html - Make height of input and div equal to their parent -


i've got following code:

.wrapper {    display: flex;    height: 25px;  }  .myinput {    width: 50px;    height: 100%;    border: 1px solid grey;    border-right: none;  }  .myinputaddon {    width: 25px;    height: 100%;    background-color: green;    border: 1px solid green;  }
<div class="wrapper">    <input class="myinput">    <div class="myinputaddon" type="number"></div>  </div>

i thought, when give hardcoded height wrapper div (in example 25px) , height: 100%; child-elements, flex correctly , have same height.

but in snippet, input higher div.

if remove height wrapper div , give input height 23px , child-div 25px, works. set little bit dynamically.

it should this:

enter image description here

how can this?

thanks , cheers.

the problem default padding of input element can add box-sizing: border-box , keep padding inside height of element.

.wrapper {    display: flex;    height: 25px;  }  .wrapper * {    box-sizing: border-box;  }  .myinput {    width: 50px;    height: 100%;    border: 1px solid grey;    border-right: none;  }  .myinputaddon {    width: 25px;    height: 100%;    background-color: green;    border: 1px solid green;  }
<div class="wrapper">    <input class="myinput">      <div class="myinputaddon" type="number"></div>  </div>


Comments

Popular posts from this blog

sql - invalid in the select list because it is not contained in either an aggregate function -

Angularjs unit testing - ng-disabled not working when adding text to textarea -

How to start daemon on android by adb -