问题描述
我有一个div
,用户可以编辑其内容,因为它具有属性contenteditable="true"
。
用户可以在其中键入中文,日文或韩文文本,并将其样式设置为粗体,斜体或下划线。
所有功能在Firefox中均可正常运行。但不在Chrome或Edge中(尚未在其他浏览器上进行测试)。在Chrome中,我无法将日语假名设为斜体。其他一切正常。
我确实知道,斜体字符不是真正的日语母语文本中使用的东西,但是我仍然确实需要此功能。
我尝试使用<i>
,<em>
,使用CSS来制作font-style: italic
,font-style: oblique
...对于Chrome浏览器似乎无效。
我该怎么办?
这是我的代码(我不能用斜体显示的部分是“ かな”,位于“ 日语假名:”前面,在第三行):
function styleText(x) {
document.execCommand(x);
}
body {
padding: 10px;
font-family: sans-serif;
}
input {
padding: 5px;
outline: 0;
font-weight: bold;
}
div {
margin: 10px 0;
width: 200px;
border: solid 1px #000;
padding: 5px;
}
<input type="button" value="Bold" onclick="styleText('bold');">
<input type="button" value="Italic" onclick="styleText('italic');">
<input type="button" value="Underline" onclick="styleText('underline');">
<div contenteditable="true">
Chinese Hanzi: 汉字<br>
Japanese Kanji: 漢字<br>
Japanese Kana: かな<br>
Korean Hangul: 한글
</div>
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)