javascript – HTML / CSS / JS rubbery Input

Question:

Hi guys! Faced the following problem: You need to typeset a rubber input so that when typing, it stretches to fit the content and moves everything that is on the side (if it is in the text). Here is an example of a form, you need to do exactly the same: http://significa.pt/enquiry/ But as I looked Here the form is made through divs and it looks like all inputs are hidden and from divs value is transferred to inputs and then they are sent to the mail. Help with this, how to implement it?

Answer:

document.querySelector('input').addEventListener('input', function () {
  this.style.width = 0;
  this.style.width = this.scrollWidth + 'px';
});
<input autofocus style=width:0>
Scroll to Top