Can You Create a Text Input with Dynamic Width?

I have users first and last name a separate items in my database but need to give users the option to edit them.

This is a purely UI/UX issue but it’s jarring to see elements jump around when you show/hide the correctly aligned elements with the editable text inputs that are massive in comparison.

Is there a way to make the text input dynamically resize based on the text it contains? That way I can remove two unrequired elements and just change the text input’s formatting.