html - 重复 css 图像作为内容

标签 html css asp.net

我需要一个图像重复并且在屏幕上和打印时都可见。目前使用

body {
    background:url(images/confidential.png) repeat;
}

@media Print {
    body:before { 
         content: url(images/confidential.png);
         position: absolute;
         z-index: -1;
    }
}

打印时重复除外。建议?谢谢。

最佳答案

大多数浏览器的默认行为是不打印背景颜色。 但是 imageSVG 和属性 content 做得很好。

使用SVG解决方案(填充图案)来实现像重复图像背景:

https://jsfiddle.net/k459wv6w/

<svg height="0" width="0" xmlns="http://www.w3.org/2000/svg" version="1.1"> 
  <defs> 
    <pattern id="rainbow" patternUnits="userSpaceOnUse" width="300" height="300"> 
      <image xlink:href="http://www.fnordware.com/superpng/pnggrad8rgb.png" 
        x="0" y="0" width="300" height="300">
      </image> 
    </pattern> 
  </defs> 
</svg>
<svg height="100%" width="100%" style="float:left" class="pattern-swatch">
  <rect style="fill: url(#rainbow) #fff;" x="0" y="0" height="100%" width="100%"></rect>
</svg>

关于html - 重复 css 图像作为内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37751583/

相关文章:

jquery - 如何找到具有特定值的子元素并删除其直接父节点?

javascript - 客户端pdf javascript插件,pdf支持多种语言

php - 试图将我的嵌入照片库(来自 tinymce 编辑器)对齐在我的模态 div 的中心

html - 如何在保持宽高比的同时调整带标题的图像大小

css - 如何使用 adf 更改字体系列

c# - 托管环境中的多线程 Pinvoked DLL。是否可以?

javascript - 寻找SVG的中心点坐标

html - SCSS : Fixed and fluid table-cells

javascript - 将 Div 内容保存为服务器上的图像

c# - Jquery 数据表 ASP.NET Gridview 大型数据集