2

我正在检查一个网站的代码,我注意到它们通过 CSS 对元素的背景属性有一个不寻常的值。这似乎是一个渐变。有谁知道它是什么?如果有效?哪些浏览器支持它?

这是代码:

background:transparent url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEwMCAxMDAiIHByZXNlcnZlQXNwZWN0UmF0aW89Im5vbmUiPjxsaW5lYXJHcmFkaWVudCBpZD0iaGF0MCIgZ3JhZGllbnRVbml0cz0ib2JqZWN0Qm91bmRpbmdCb3giIHgxPSI1MCUiIHkxPSIxMDAlIiB4Mj0iNTAlIiB5Mj0iLTEuNDIxMDg1NDcxNTIwMmUtMTQlIj4KPHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iI2ZmZiIgc3RvcC1vcGFjaXR5PSIwLjY1Ii8+CjxzdG9wIG9mZnNldD0iMTAwJSIgc3RvcC1jb2xvcj0iI2ZmZiIgc3RvcC1vcGFjaXR5PSIwLjkiLz4KICAgPC9saW5lYXJHcmFkaWVudD4KCjxyZWN0IHg9IjAiIHk9IjAiIHdpZHRoPSIxMDAiIGhlaWdodD0iMTAwIiBmaWxsPSJ1cmwoI2hhdDApIiAvPgo8L3N2Zz4=);

我感谢任何和所有的帮助!

提前致谢!:-)

4

3 回答 3

4

好吧,首先要做的是对它进行de-base64

<?xml version="1.0" ?>
<svg xmlns="http://www.w3.org/2000/svg" width="100%" height="100%" viewBox="0 0 100 100" preserveAspectRatio="none">
    <linearGradient id="hat0" gradientUnits="objectBoundingBox" x1="50%" y1="100%" x2="50%" y2="0%">
        <stop offset="0%" stop-color="#fff" stop-opacity="0.65" />
        <stop offset="100%" stop-color="#fff" stop-opacity="0.9" />
    </linearGradient>
    <rect x="0" y="0" width="100" height="100" fill="url(#hat0)" />
</svg>

因此,您可以看到是的,它是一个渐变。非 IE 浏览器支持,IE 9+ 也支持。

于 2012-07-15T22:09:33.020 回答
1

它是 base64 编码的 SVG 文件。此约定是使用 SVG 图形文件作为嵌入背景图像的一种方式。我在这里使用 Travelocity 徽标做同样的事情http://mailmarkup.org/slideshow.xhtml

于 2012-07-15T22:08:19.853 回答
1

I think all modern browsers support it. This is a scalable vector graphic (you often find those used for maps on wikipedia) file that is base64-encoded, that means it consists many bytes which wer converted to be used in ASCII character sets.

于 2012-07-15T22:09:50.430 回答