【发布时间】:2017-01-17 14:31:08
【问题描述】:
嗨! 有人可以回答我的问题吗?我用 CSS + Javascript 开发了一个简单的雾效果。它在 Firefox、Opera 和 Chrome 上运行良好。该问题仅存在于 IE 和 Edge 上。该效果使用 JS 在桌面(div 标签)上移动两个背景图像。 Microsoft 网络浏览器显示除了纹理之外的奇怪框。它看起来像一个副作用。问题将在该站点中找到:
CSS:
#fog_one {
background-repeat: repeat-x, repeat-x;
background-attachment: fixed, fixed;
background-image: url(/obrazy/marmur.png), url(/obrazy/marmur.png);
background-size: 128% 132%, 110% 128%;
z-index: -2;
position: fixed;
left: 0;
top: 0;
right: 0;
bottom: 0;
}
Javascript:
var fog_one;
function RenderFog()
{
var Mil = MonadTimeVar.getMilliSeconds();
fog_one.style.backgroundPosition = ''.concat(Math.ceil(Mil / 48),
'px ', Math.ceil(Math.sin(Mil / 1024) * Math.sin(Mil / 1240) * 8), 'px',
',', Math.ceil(-Mil / 72), 'px ', Math.ceil(Math.cos(Mil / 920) * 12),
'px');
}
function FogLoaded()
{
fog_one=document.getElementById('fog_one');
return setInterval(RenderFog,30);
}
有解决办法吗,是我的错误吗?
【问题讨论】:
-
检查您对
background-position-x位置的计算:这些值只是在增长,而不是上下循环,您似乎正在尝试这样做? (这是在边缘)。还有为什么你将两个值传递给background-position-x和background-position-y,这对我来说没有多大意义。 -
@sweaver2112 感谢您对帖子发表评论。我的想法是浏览器应该默认循环,即使值不断增长。我在一个 div 标记内呈现了两个背景图像(同一个文件),它可以工作。
标签: javascript html css internet-explorer microsoft-edge