Unusual shape of a textarea?

后端 未结 10 777
無奈伤痛
無奈伤痛 2020-11-29 15:03

Usually textareas are rectangular or square, like this:

\"Usual

But I want a custom-shaped

10条回答
  •  有刺的猬
    2020-11-29 15:21

    If, for whatever reason, you really need to support browsers that don't have contenteditable, you could probably do the same thing in JavaScript, by using events, although this is a very messy workaround.

    Pseudocode:

    focused=false;
    when user clicks the div
        {
        focused=true;
        }
    when user clicks outside the div
        {
        focused=false;
        }
    when user presses a key
        {
        if (focused)
        {
        add character of key to div.innerHTML;
        }
        }
    

提交回复
热议问题