如何使用SVG图片作为背景?

编程入门 行业动态 更新时间:2024-10-24 13:31:21
本文介绍了如何使用SVG图片作为背景?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我必须做错事。该图像作为SVG从图形输出,(我不知道这是否相关),它有一些像素数据。 这是我的JSFiddle示例。

I must be doing something wrong. The image was exported from illustrator as an SVG and (I'm not sure whether this is relevant or not) it does have some pixel data in it. Here's my JSFiddle example.

请注意,直接图片,它显示得很好: ykcreations/tv.svg

Note that going directly to the image, it shows up just fine: ykcreations/tv.svg

修改:此选项在Chrome或Safari中无法使用,但在Firefox中却无法使用。 Webkit问题?

推荐答案

您的源SVG有问题。查看此更新的指向其他SVG文件的更正指向:jsfiddle/wdW2K/2/

There is a problem with your source SVG. See this updated Fiddle pointing to a different SVG file that works correctly: jsfiddle/wdW2K/2/

.tv { background: url("phrogz/svg/800x800.svg"); width: 400px; height: 400px; }​

编辑:具体来说, >出现是因为WebKit不支持用作背景的SVG中的< image> 。最低限度修改您的文件以将< image> 更改为引用本地(非数据uri)文件,并添加< circle / > ,在Chrome中直接查看SVG时,我可以看到图片和圆圈,但当用作背景图片时,只有该圆圈可见。

Edit: Specifically, the problem appears to be that WebKit does not support <image> in an SVG used as a background. Modifying your file minimally to change the <image> to reference a local (non-data-uri) file, and adding a <circle/>, I was able to see both the image and circle when viewing the SVG directly in Chrome, but when used as a background image only the circle was visible.

这个错误闻起来相关。

更多推荐

如何使用SVG图片作为背景?

本文发布于:2023-11-26 20:06:16,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1635002.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何使用   背景   图片   SVG

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!