jQuery execCommand for superscript and subscript n

2019-08-07 18:01发布

I'm trying to create a text editor using jQuery and execCommand. Everything was going good until I noticed that both superscript and subscript aren't properly toggling.

This jsFiddle (http://jsfiddle.net/k8F4P/) should illustrate the problem.

It is possible that it is simply my browser, but I'm using the latest version of Chrome for Mac.

1条回答
Evening l夕情丶
2楼-- · 2019-08-07 18:14

Turned out the issue was that the stylesheet normalize.css was setting the sub and sup tags' vertical-align to baseline and this was preventing the correct toggling, but only in Chrome. The simple solution is to set sub to vertical-align: sub and sup to vertical-align: super.

查看更多
登录 后发表回答