{"id":1778,"date":"2017-10-28T18:16:52","date_gmt":"2017-10-28T09:16:52","guid":{"rendered":"https:\/\/ani2life.com\/wp\/?p=1778"},"modified":"2017-10-28T18:33:19","modified_gmt":"2017-10-28T09:33:19","slug":"textarea-%ec%9e%90%eb%8f%99-%eb%86%92%ec%9d%b4-%eb%a7%9e%ec%b6%94%ea%b8%b0-javascript-%ec%98%88%ec%a0%9c","status":"publish","type":"post","link":"https:\/\/ani2life.com\/wp\/?p=1778","title":{"rendered":"textarea \uc790\ub3d9 \ub192\uc774 \ub9de\ucd94\uae30 Javascript \uc608\uc81c"},"content":{"rendered":"<p>\uc544\ub798\ub294 textarea\uc5d0 \uc791\uc131\ub41c \ub0b4\uc6a9\uc758 \uae38\uc774\uc5d0 \ub9de\ucdb0 style\uc758 height\ub97c \uacc4\uc0b0\ud558\ub294 \uc608\uc81c\uc774\ub2e4.<\/p>\n<pre data-start-line=\"1\" data-visibility=\"visible\" data-highlight=\"\" data-caption=\"\" class=\"prettyprint lang-javascript\">function textareaAutoHeight(el) {\r\n    setTimeout(() =&gt; {\r\n        el.style.height = 'auto';\r\n\r\n        let scrollHeight = el.scrollHeight;\r\n        let outlineHeight = el.offsetHeight - el.clientHeight;\r\n\r\n        el.style.height = (scrollHeight + outlineHeight) + 'px';\r\n    }, 0);\r\n}<\/pre>\n<p>\uc704 \ucf54\ub4dc\ub294 textarea\uc758 \uc2a4\ud0c0\uc77c\uc774 box-sizing: border-box;\uc77c \ub54c \uc644\ubcbd\ud558\uac8c \ub3d9\uc791\ud55c\ub2e4.<\/p>\n<p>\uc704 \ucf54\ub4dc\uc5d0\uc11c \uc911\uc694\ud55c \ubd80\ubd84\uc740 \ubc14\uae65\ucabd\uc744 \ud3ec\ud568\ud55c \ub192\uc774 offsetHeight\uc640 \uc548\ucabd\uc758 \ub192\uc774 clientHeight\uc758 \ucc28\ub97c textarea \ub192\uc774\uc5d0 \ub354\ud574\uc900\ub2e4\ub294 \uac83\uc774\ub2e4.<\/p>\n<p>\ub9cc\uc57d \uc774 \uacc4\uc0b0\uc744 \ud3ec\ud568\ud558\uc9c0 \uc54a\uc73c\uba74 textarea\uc5d0 \ud14c\ub450\ub9ac(border)\uac00 \uc788\uc744 \uacbd\uc6b0\uc5d0 \ud14c\ub450\ub9ac\uc758 \uc704(border-top-width) + \uc544\ub798(border-bottom-width) \ub9cc\ud07c \uc190\ud574\ub97c \ubcf4\uac8c \ub41c\ub2e4.<\/p>\n<p>\uc8fc\uc758\ud560 \uc810\uc740 border-width \uac12\uc744 \uc9c1\uc811 \ub354\ud574\uc8fc\uba74 \uc548\ub41c\ub2e4. border-width\uc758 \ub2e8\uc704\ub294 \ud53d\uc140(px)\uc774 \uc544\ub2d0 \uc218\ub3c4 \uc788\ub2e4. \uadf8\ub807\uae30 \ub54c\ubb38\uc5d0 element \uac1d\uccb4\uc758 offsetHeight &#8211; clientHeight \ub85c \ud14c\ub450\ub9ac\uc758 \ub192\uc774\ub97c \uad6c\ud574\uc57c \ud55c\ub2e4.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\uc544\ub798\ub294 textarea\uc5d0 \uc791\uc131\ub41c \ub0b4\uc6a9\uc758 \uae38\uc774\uc5d0 \ub9de\ucdb0 style\uc758 height\ub97c \uacc4\uc0b0\ud558\ub294 \uc608\uc81c\uc774\ub2e4. function textareaAutoHeight(el) { setTimeout(() =&gt; { el.style.height = &#8216;auto&#8217;; let scrollHeight = el.scrollHeight; let outlineHeight = el.offsetHeight &#8211; el.clientHeight; el.style.height = (scrollHeight + outlineHeight) + &#8216;px&#8217;; }, 0); } \uc704 \ucf54\ub4dc\ub294 textarea\uc758 \uc2a4\ud0c0\uc77c\uc774 box-sizing: border-box;\uc77c \ub54c \uc644\ubcbd\ud558\uac8c \ub3d9\uc791\ud55c\ub2e4. \uc704 \ucf54\ub4dc\uc5d0\uc11c \uc911\uc694\ud55c \ubd80\ubd84\uc740 \ubc14\uae65\ucabd\uc744 \ud3ec\ud568\ud55c \ub192\uc774 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[7],"tags":[145,542],"_links":{"self":[{"href":"https:\/\/ani2life.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/1778"}],"collection":[{"href":"https:\/\/ani2life.com\/wp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ani2life.com\/wp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ani2life.com\/wp\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ani2life.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1778"}],"version-history":[{"count":9,"href":"https:\/\/ani2life.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/1778\/revisions"}],"predecessor-version":[{"id":1787,"href":"https:\/\/ani2life.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/1778\/revisions\/1787"}],"wp:attachment":[{"href":"https:\/\/ani2life.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1778"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ani2life.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1778"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ani2life.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1778"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}