html - 圆圈的 CSS 样式 <figure> 不会显示在打印 View 中

标签 html css printing background figure

我创建了一些带有图形 html 元素和 css 样式的 3D 球体,但我无法在打印 View 中显示它们。我正在尝试使用 IE9 和 Chrome v45。我该怎么做才能打印这些内容?我希望答案不是将元素更改为图形以外的其他内容,因为这需要进行许多其他更改。

我有 -- 在 IE 打印对话框中选中“打印背景颜色和图像”,我在 Chrome 打印对话框中选中“背景图形”。 -- 尝试添加 -webkit-print-color-adjust: exact;到 css 中的许多地方,包括 figure{}、.sphere{} 和 .red{} -- 尝试添加一个 print-backgrounds chrome 扩展,后来我才知道它已经过时了。

HTML:

<figure class="red sphere"></figure>

Chrome 的 CSS:

.sphere {
  display: block; 
  -moz-border-radius: 50%;
  -webkit-border-radius: 50%;
  border-radius: 50%;  
  height: 30px;
  width: 30px;
  margin: 5px auto auto auto;  
}

.red {
    background: radial-gradient(circle at 10px 10px, red, #000);  
}

IE9 的 CSS:

.sphere {
  display: block;
  -moz-border-radius: 50%;
  -webkit-border-radius: 50%;
  border-radius: 50%;  
  height: 30px;
  width: 30px;
  margin: 5px auto auto auto;
  filter:progid:DXImageTransform.Microsoft.Alpha(opacity=100, finishopacity=40, style=2);
}

.red {
    background: red; 
}

谢谢!

最佳答案

链接样式表时确保有 media=all在链接中。

它应该看起来像这样:

<link rel="stylesheet" type="text/css" media="all" href="styles.css">

或设置一个特定的print像这样的样式表:

<link rel="stylesheet" type="text/css" media="print" href="print.css">

关于html - 圆圈的 CSS 样式 <figure> 不会显示在打印 View 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33739661/

相关文章:

Javascript 重复音频

php - 如何创建触发文件打印的链接?

php - 仅打印一次数组中的值

javascript - 在每次页面加载时自动将本地存储数据从 chrome 扩展传递到内容脚本

html - 如果窗口比例改变,我如何设置我的图像调整大小和移动

javascript - 附加 defs 标签并在 D3.js 的 SVG 中使用它

c# - WP8 : Setting Image width to device width in Webbrowser Control

javascript - 如何让媒体查询与切换功能添加的样式一起使用

css - 像按钮一样调整 facebook 的大小?

python - 打印一个相当具体的矩阵