简体   繁体   English

HTML页面上的键盘光标位置使用“缩放”错误

[英]Wrong keyboard cursor position on HTML page with uses “scale”

When you create a new contenteditable <span> on a page where scale is used, the keyboard cursor is sometimes put at a wrong position with Firefox. 在使用scale的页面上创建新的contenteditable <span>时,有时Firefox会将键盘光标放在错误的位置。

在此处输入图片说明

Example : click on the right side of the window in the following snippet example : the "Strawberry" text will appear, but the I keyboard cursor will be in a wrong position. 示例:在以下代码段示例中,单击窗口的右侧:将显示“草莓”文本,但是I键盘光标将位于错误的位置。

How to have a good I keyboard cursor position for contenteditable objects ? 如何为contenteditable对象提供良好的I键盘光标位置?


  window.onload = function() { var container = document.createElement("div"), wrapper = document.createElement("div"); container.style.position = "absolute"; wrapper.style.position = "relative"; container.appendChild(wrapper); document.body.appendChild(container); container.style.transform = "scale(0.6)"; zoom = 0.6; window.onclick = function(e) { if (e.target.className == 'texte') { return; } var tb = document.createElement('span'); tb.className = "texte"; tb.contentEditable = true; tb.style.fontSize = '40px'; tb.style.position = 'absolute'; tb.textContent = 'strawberry'; tb.style.top = e.clientY / zoom + 'px'; tb.style.left = e.clientX / zoom + 'px'; wrapper.appendChild(tb); tb.focus(); } } 
 <!DOCTYPE html> <html> <head> <title>Text map</title> </head> <body> </body> </html> 

对我来说,运行您的代码段光标似乎在正确的位置上很好.....

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM