Dealing with line Breaks on contentEditable DIV

后端 未结 7 1778
粉色の甜心
粉色の甜心 2020-11-27 12:41

I have a problem with contenteditable line breaks on SAFARI/CHROME. When I press \"return\" on a contentEditable

, instead of creating a
7条回答
  •  眼角桃花
    2020-11-27 13:12

    Webkits won’t render a single br if it’s the last (non-empty) child of a container. For Safari, the native keystroke to insert a line break is Ctrl + Return. If you look closely, you notice that Safari actually inserts two brs while only rendering one; however, it will insert a single br if there is some trailing text, or will get rid of double brs once you enter some (if there were doubles).

    Apparently, it seems a solution for Webkits is to insert double brs as they themselves do, and let them handle the rest.

提交回复
热议问题