Multiline questionaire editable

你说的曾经没有我的故事 提交于 2019-12-07 08:45:31

To cover unknown line-height one can use JavaScript to determine the line-height by adding a line of text and measure the height-difference. In a second step, when height contains the line-height inside the editable area you can dynamically generate a background-image:

var svg = "<svg xmlns='http://www.w3.org/2000/svg' width='1' height='" + height + "'><line x1='0' y1='" + height + "' x2='1' y2='" + height + "' stroke='black' stroke-width='1px'/></svg>";
your_element.setAttribute('style','background-image: url("data:image/svg+xml;utf8,' + svg + '")}');

This creates an svg-image which may be a compatiblity issue. If you need wide cross-browser support, you could also:

  • just store images with all possible heights
  • create a gif/png on the fly and encode it using base64

In my case it only had to be working in the iPad-App iBook for reading *.ePUB-Books.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!