0

我正在尝试将我的网站的背景图像设置为 SVG。我尝试使用的 SVG 来自http://svgeneration.com/generate/GPlay 我已经使用这个 SVG 作为纯 html 文件中的正文背景进行了测试,它运行良好。当尝试将 SVG 的 css 添加到我的实际网站时,网站结构和 css 混乱并且没有任何 css 被呈现......它看起来就像一个没有任何 css 样式的页面。这就像一旦浏览器读取正文背景 css,它就会停在那里并且不会继续。因此,剩下的 SVG 没有显示为背景,页面的其余部分 css 没有呈现。对于我的网站,我使用的是 SocialEngine ( http://www.socialengine.com/ )。会不会是这个平台不喜欢使用 SVG?

这是我添加的css

    body {
    background-color: #f0f0f0;background-image:url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0naHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmcnIHhtbG5zOnhsaW5rPSdodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rJyB3aWR0aD0nNDkxLjk5OTk5OTk5OTk5OTk0JyBoZWlnaHQ9JzI1Mi4wMDAwMDAwMDAwMDAwMycgdmlld0JveD0nMCAwIDk4LjM5OTk5OTk5OTk5OTk5IDUwLjQwMDAwMDAwMDAwMDAwNic+Cgk8ZGVmcz4KCQk8cGF0aCBpZD0ncycgZmlsbD0nI2ZmZmZmZicgZD0nTTAsMGw4IDRsLTgsNHonLz4KCTwvZGVmcz4KCTxnIGlkPSdiJz4KCTx1c2UgeD0nLTgnIHk9Jy00JyB0cmFuc2Zvcm09J21hdHJpeCgtMSAwIDAgMSAwIDApJyBmaWxsLW9wYWNpdHk9JzAuMycgeGxpbms6aHJlZj0nI3MnIC8+Cgk8dXNlIHg9JzAnIHk9JzAuMicgZmlsbC1vcGFjaXR5PScwLjQ0OTk5OTk5OTk5OTk5OTk2JyB4bGluazpocmVmPScjcycgLz4KCTx1c2UgeD0nLTgnIHk9JzQuNCcgdHJhbnNmb3JtPSdtYXRyaXgoLTEgMCAwIDEgMCAwKScgZmlsbC1vcGFjaXR5PScwLjQ0OTk5OTk5OTk5OTk5OTk2JyB4bGluazp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5OTk5OTk5OTk5OTknIHk9JzE3JyB0cmFuc2Zvcm09J21hdHJpeCgtMSAwIDAgMSAwIDApJyBmaWxsLW9wYWNpdHk9JzAuMycgeGxpbms6aHJlZj0nI3MnIC8+Cgk8dXNlIHg9JzQxJyB5PScyMS4yJyBmaWxsLW9wYWNpdHk9JzAuMycgeGxpbms6aHJlZj0nI3MnIC8+Cgk8L2c+Cgk8dXNlIHg9Jy00OC45OTk5OTk5OTk5OTk5OScgeT0nMjUuMjAwMDAwMDAwMDAwMDAzJyB0cmFuc2Zvcm09J21hdHJpeCgtMSAwIDAgMSAwIDApJyB4bGluazpocmVmPScjYicgLz4KCTx1c2UgeD0nLTk4LjE5OTk5OTk5OTk5OTk5JyB5PSctMTYuOCcgdHJhbnNmb3JtPSdtYXRyaXgoLTEgMCAwIC0xIDAgMCknIHhsaW5rOmhyZWY9JyNiJyAvPgoJPHVzZSB4PSc0OS4xOTk5OTk5OTk5OTk5OTYnIHk9Jy0zMy42JyB0cmFuc2Zvcm09J21hdHJpeCgxIDAgMCAtMSAwIDApJyB4bGluazpocmVmPScjYicgLz4KCTx1c2UgeD0nNDkuMTk5OTk5OTk5OTk5OTk2JyB5PSctNTguODAwMDAwMDAwMDAwMDA0JyB0cmFuc2Zvcm09J21hdHJpeCgxIDAgMCAtMSAwIDApJyB4bGluazpocmVmPScjYicgLz4KPC9zdmc+Cg==');
    }

这是 svgeneration 链接中给出的代码

4

2 回答 2

0

尝试在包含所有内容的 body 元素中放置另一个 div。根据页面的内容,有时 body 元素不会跨越整个页面。

因此,您可能可以执行以下操作:

HTML

<body>
<div class='content_wrapper'>
  <!--Page Content is here-->
</div>
</body>

CSS

.content_wrapper{
background: #f0f0f0;
background-image:url('data:image/svg+xml;base64,....');
}
于 2013-08-20T20:47:18.170 回答
0

您发布的代码没有问题。这是一个 jsFiddle 显示

这意味着它很可能是 SocialEngine 的问题,但在我们假设您应该将当前拥有的代码复制并粘贴到 jsFiddle 或其他编辑器中以查看它是否有效之前。问题不在于您迄今为止提供给我们的任何东西

我确实注意到的一件事是,该background-image行之后的代码格式似乎不正确(它在 jsFiddle 中变成蓝色,就像它是一个值一样),但它仍然可以正常运行。您可以尝试在该background-image行之前放置您拥有的任何代码,看看是否也可以修复它

于 2013-08-20T20:51:29.117 回答