MS Word复制文本来自HTML PRE元素,其内部元素具有font-family设置为继承的,导致font-fominy not far by by by corcrecty设置
我遇到了这个问题,在将pre> pre
标记中的文本复制到Microsoft Word中时,将复制的字体家庭设置为第一个计算的font for for该元素。例如,如果*
具有font-family:sashit
文本复制的字体 - 家庭将设置为Microsoft Word中的sashit
没有其他字体家庭
直接为该对象设置。
如果使用Div
更改了PRE> PRE
标签,则不会发生此问题,但这在我的情况下是不可能的。
是否有人知道一种修复此操作的方法,以使正确的字体复制,在该字体中仍将字体家庭应用于pre> pre
元素。
演示代码
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="test.css">
<title>Document</title>
</head>
<body>
<pre><code><span>This is text</span></code></pre>
</body>
</html>
test.css
*{
font-family: inherit;
}
pre {
font-family: Verdana,Helvetica,Arial,sans-serif;
}
I am having this problem where when copying text from within a pre
tag into microsoft word, the font-family being copied is set to the first computed font-family for the element. For example if *
has font-family: inherit
the copied font-family for the text would be set to inherit
in microsoft word, if there is no other font-family
set directly for that object.
This problem does not occur if the pre
tag is changed out with a div
, but this is not possible in my case.
Does anybody know a way to fix this such that the correct font is copied, where the font-family is still being applied to the pre
element.
Demo code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="test.css">
<title>Document</title>
</head>
<body>
<pre><code><span>This is text</span></code></pre>
</body>
</html>
test.css
*{
font-family: inherit;
}
pre {
font-family: Verdana,Helvetica,Arial,sans-serif;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论