jQuery execCommand的上标和下标未正确切换 [英] jQuery execCommand for superscript and subscript not properly toggling

查看:157
本文介绍了jQuery execCommand的上标和下标未正确切换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用jQuery和execCommand创建文本编辑器.一切都进行得很好,直到我注意到superscriptsubscript都没有正确切换.

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.csssubsup标记的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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆