我正在尝试将我网站的背景图片设置为SVG。我试图使用的SVG来自http://svgeneration.com/generate/GPlay 我已经测试过使用这个SVG作为普通html文件中的正文背景,它运行正常。当试图将SVG的CSS添加到我的实际网站时,网站结构和CSS混乱并且没有任何css被渲染......它看起来就像没有任何CSS样式的页面。就像浏览器读取身体背景css一样,它停在那里并且不会继续。因此,它留下了SVG没有显示为背景而页面的其余部分没有呈现。对于我的网站,我使用的是SocialEngine(http://www.socialengine.com/)。这个平台是不是喜欢使用SVG呢?
这是我添加的CSS
body {
background-color: #f0f0f0;background-image:url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0naHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmcnIHhtbG5zOnhsaW5rPSdodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rJyB3aWR0aD0nNDkxLjk5OTk5OTk5OTk5OTk0JyBoZWlnaHQ9JzI1Mi4wMDAwMDAwMDAwMDAwMycgdmlld0JveD0nMCAwIDk4LjM5OTk5OTk5OTk5OTk5IDUwLjQwMDAwMDAwMDAwMDAwNic+Cgk8ZGVmcz4KCQk8cGF0aCBpZD0ncycgZmlsbD0nI2ZmZmZmZicgZD0nTTAsMGw4IDRsLTgsNHonLz4KCTwvZGVmcz4KCTxnIGlkPSdiJz4KCTx1c2UgeD0nLTgnIHk9Jy00JyB0cmFuc2Zvcm09J21hdHJpeCgtMSAwIDAgMSAwIDApJyBmaWxsLW9wYWNpdHk9JzAuMycgeGxpbms6aHJlZj0nI3MnIC8+Cgk8dXNlIHg9JzAnIHk9JzAuMicgZmlsbC1vcGFjaXR5PScwLjQ0OTk5OTk5OTk5OTk5OTk2JyB4bGluazpocmVmPScjcycgLz4KCTx1c2UgeD0nLTgnIHk9JzQuNCcgdHJhbnNmb3JtPSdtYXRyaXgoLTEgMCAwIDEgMCAwKScgZmlsbC1vcGFjaXR5PScwLjQ0OTk5OTk5OTk5OTk5OTk2JyB4bGluazpocmVmPScjcycgLz4KCTx1c2UgeD0nMCcgeT0n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Zvcm09J21hdHJpeCgtMSAwIDAgMSAwIDApJyBmaWxsLW9wYWNpdHk9JzAuMycgeGxpbms6aHJlZj0nI3MnIC8+Cgk8dXNlIHg9JzQxJyB5PScyMS4yJyBmaWxsLW9wYWNpdHk9JzAuMycgeGxpbms6aHJlZj0nI3MnIC8+Cgk8L2c+Cgk8dXNlIHg9Jy00OC45OTk5OTk5OTk5OTk5OScgeT0nMjUuMjAwMDAwMDAwMDAwMDAzJyB0cmFuc2Zvcm09J21hdHJpeCgtMSAwIDAgMSAwIDApJyB4bGluazpocmVmPScjYicgLz4KCTx1c2UgeD0nLTk4LjE5OTk5OTk5OTk5OTk5JyB5PSctMTYuOCcgdHJhbnNmb3JtPSdtYXRyaXgoLTEgMCAwIC0xIDAgMCknIHhsaW5rOmhyZWY9JyNiJyAvPgoJPHVzZSB4PSc0OS4xOTk5OTk5OTk5OTk5OTYnIHk9Jy0zMy42JyB0cmFuc2Zvcm09J21hdHJpeCgxIDAgMCAtMSAwIDApJyB4bGluazpocmVmPScjYicgLz4KCTx1c2UgeD0nNDkuMTk5OTk5OTk5OTk5OTk2JyB5PSctNTguODAwMDAwMDAwMDAwMDA0JyB0cmFuc2Zvcm09J21hdHJpeCgxIDAgMCAtMSAwIDApJyB4bGluazpocmVmPScjYicgLz4KPC9zdmc+Cg==');
}
这是svgeneration链接中给出的代码
答案 0 :(得分:0)
尝试将另一个div放在包裹所有内容的body元素中。根据页面的内容,有时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,....');
}
答案 1 :(得分:0)
您发布的代码没有问题。 Here is a jsFiddle showing so
这意味着它很可能是SocialEngine的一个问题,但在我们假设您应该将您当前拥有的代码复制并粘贴到jsFiddle或其他编辑器中以查看它是否有效。问题不在于您迄今为止提供给我们的任何内容
我注意到的一件事是background-image
行之后的代码出现格式不正确(它在jsFiddle中变为蓝色,就像它是一个值),但它仍能正常运行。您可以尝试在background-image
行之前放置您拥有的任何代码,看看是否也能修复它