jQuery execCommand的上标和下标未正确切换 [英] jQuery execCommand for superscript and subscript not properly toggling
问题描述
我正在尝试使用jQuery和execCommand
创建文本编辑器.一切都进行得很好,直到我注意到superscript
和subscript
都没有正确切换.
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.
此jsFiddle( http://jsfiddle.net/k8F4P/)应该可以说明问题.
This jsFiddle (http://jsfiddle.net/k8F4P/) should illustrate the problem.
可能只是我的浏览器,但我使用的是最新版的Mac版Chrome.
It is possible that it is simply my browser, but I'm using the latest version of Chrome for Mac.
推荐答案
原来的问题是样式表normalize.css
将sub
和sup
标记的vertical-align
设置为baseline
,这是阻止正确切换,但仅限于Chrome浏览器.简单的解决方案是将sub
设置为vertical-align: sub
,将sup
设置为vertical-align: super
.
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
.
这篇关于jQuery execCommand的上标和下标未正确切换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!