0

我只是想找出一种在 iOS 应用程序中使用快速输出的 HTML5 动画的方法,但我不能放弃灰色背景。我认为这将是一种将动画放入其中并规避在视网膜 iPad 显示器上使用 png 的存储问题的方法。现在我无法使背景清晰。我应该怎么办?

4

6 回答 6

3

在 Swiffy 生成的代码中,查找 backgroundColor 并删除它,包括它的值。

于 2012-11-21T15:03:44.773 回答
0

尝试找到具有纯色背景的元素并将其动态更改为透明,如下所示:

document.getElementById('swiffycontainer').childNodes[1].style.background = "rgba(255, 255, 255, 0)";

或无

document.getElementById('swiffycontainer').childNodes[1].style.background = "none";
于 2013-06-11T12:03:33.720 回答
0

将此添加到您的 CSS 或类似内容中。

#containerdivid svg > g > g > rect {
    display: none;
}
于 2014-05-10T15:51:53.883 回答
0

根据http://css-tricks.com/override-inline-styles-with-css/,您可以使用这个 CSS hack

div[id=swiffycontainer] > div{
    background-color: transparent!important;
}
于 2013-06-28T16:42:17.620 回答
0

删除 backgroundColor: 元素对我不起作用,直到我发现 Google 在当前版本的 Swiffy 运行时中破坏了这样做的能力。如果你也改变:

src="https://www.gstatic.com/swiffy/v5.2/runtime.js"

src="https://www.gstatic.com/swiffy/v5.1/runtime.js"

在文件的顶部,您应该会发现透明背景可以正常工作(当然,5.2 库中的任何增强功能都将不再可用)。

编辑:Michael Prescott 已经指出,由于 Swiffy 转换器版本和运行时之间的不匹配,该解决方案将无法可靠地工作。不依赖于 5.1 导出器的替代解决方案是在此处建议的其他解决方案的基础上构建。尝试将以下函数添加到脚本中。它轮询查看 Swiffy 对象何时安装了它的首选背景颜色,然后替换它。

(function() {
    var firstNode=document.getElementById('swiffycontainer').childNodes[1];
    //firstNode.style.visibility = "hidden";
    if (firstNode.style.background=="") {
        setTimeout(arguments.callee, 10);
    } else {
        firstNode.style.background = "none";
        //firstNode.style.visibility = "visible";
    }
})();

当 Swiffy 首先设置一个纯色背景然后它被替换时,这似乎并没有显示出故障。但是,为了更加确定,您可以启用注释掉的行来隐藏第一个节点,直到设置了正确的透明度。

此致

于 2013-06-10T23:04:59.550 回答
0

这些都不适合我(使用 5.2 版),通过设置新样式来解决:

<script>
    var stage = new swiffy.Stage(document.getElementById('swiffycontainer'),swiffyobject);      
    stage.start();
</script>
<style> 
    div {background: url("../bgimg.jpg") repeat scroll 0 0 transparent !important;} 
</style>
于 2013-06-28T15:26:25.267 回答