Html css打印字体没有改变

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3617115/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 04:20:24  来源:igfitidea点击:

css print font not changing

htmlcss

提问by manraj82

Im designing a printer friendly page and im stuck trying to alter the font properties[font-size, font-family] in CSS.I have got no idea what im doing wrong here. The font properties i have specified for the body tag in the CSS file doesn't seem to work at all.

我设计了一个打印机友好的页面,但我一直试图改变 CSS 中的字体属性 [font-size, font-family]。我不知道我在这里做错了什么。我在 CSS 文件中为 body 标记指定的字体属性似乎根本不起作用。

Could somone please explain to me what im doing wrong here ?

有人可以向我解释我在这里做错了什么吗?

html

html

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
 <html>
  <head>
   <title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" media="print" href="print.css">
</head>

<body>
<div id="wrapper">
    <table width="100%" border="1">
        <tr >
            <td >Job No</td>
            <td>4589</td>
        </tr>
        <tr>
            <td>Job No</td>
            <td>6578</td>
        </tr>
    </table>
</div>
</body>
</html>

css

css

/* CSS Document */
div#wrapper 
{
    margin-left:auto;
    margin-right:auto;
    width:auto;

}
body {
background-color: transparent;
font-size: 12pt;
font-family:'Times New Roman',Times,serif;
color:#000000; }

采纳答案by Pekka

Try explicitly specifying the font properties for the td:

尝试明确指定 的字体属性td

table tr td {
  font-size: 12pt;
  font-family:'Times New Roman',Times,serif;
}

回答by Octavian A. Damiean

Try this CSS instead.

试试这个 CSS。

#wrapper
{
  margin-left:auto;
  margin-right:auto;
  width:auto;
}

#wrapper table
{
  font-family:"Times New Roman", Times, serif;
  font-size: 12pt;
}

body 
{
  background-color: transparent;
  font-family:"Times New Roman", Times, serif;
  font-size: 12pt;
  color:#000000; 
}