Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

contentEditable superscript & subscript in Chrome

The following DHTML formatting commands each work fine on a div with contentEditable=true in IE, Firefox and Chrome:

document.execCommand("superscript", false, null);
document.execCommand("subscript", false, null);

However, calling the command again to remove the formatting has no effect in Chrome.

Am I missing something or is this a bug in Chrome?

like image 510
Petrus Theron Avatar asked Mar 05 '11 10:03

Petrus Theron


1 Answers

I had a similar problem. For me, the problem was due to some "normalization" CSS altering vertical-align: baseline for sup and sub tags. Overriding that CSS and setting sub to vertical-align: sub and sup to vertical-align: super fixed it.

like image 108
Jonathan B Avatar answered Nov 17 '22 08:11

Jonathan B