Resize text area to fit fluid width layout using javascript

I have a fluid layout and I need a text box to expand / reduce depending on the size of the parent container.

In CSS, it will look like this:

textarea{
width: 100%;
}

But this does not work with text areas.

How can I do this using javascript? I can get the width of the parent element, and they count the number of columns matching that width, but how do I know the size of 1 col (in px)?

+3
source share
2 answers

chk this out: http://css-tricks.com/box-sizing/

  textarea {
            -webkit-box-sizing: border-box; /* Safari/Chrome, other WebKit */
            -moz-box-sizing: border-box;    /* Firefox, other Gecko */
             box-sizing: border-box;         /* Opera/IE 8+ */
           }
+13
source

2014 width: 100%; textareas Chrome, Firefox, IE, Opera Safari.

+2

Source: https://habr.com/ru/post/1768402/


All Articles