Here you need to expand the element according to the height of the content. Unfortunately, you cannot do this with CSS. Therefore, we will have to move with javascript.
Here is the script
<script> var max = 0; function setHeight() { var elements = document.getElementsByClassName('mytxt'); var height = 0; for (var i = 0; i < elements.length; i++) { height = elements[i].scrollHeight; if (height > max) { max = height; } } elements = document.getElementsByClassName('dynamictextbox'); for (var i = 0; i < elements.length; i++) { elements[i].style = "min-height: " + max + "px"; } } </script>
At the end of the whole div call funtion setHeight() .
<script>setHeight()</script>
Thus, the result will look like this: 
PS I added borders for the dynamictextbox class for testing purposes.
source share