我的背景图片在每次回发时都会重新加载。所以每次按下按钮时都会引起闪烁。它出现在 Internet Explorer(测试版本 11.0.9600.17843)和 Chrome(测试版本 45.0.2454.93 m)中。在 Firefox(测试版本 34.0.5)中它可以工作。到目前为止,我还没有测试过其他浏览器。到目前为止,这是背景图片的代码:
<style type="text/css">
body
{
background-image: url(/Img/Besuchermanagement_1920_1080.jpg);
background-attachment: inherit;
background-repeat: no-repeat;
background-position: center;
background-size: 100% 100%;
min-height: 925px;
opacity: 0.9
}
</style>
当我读到有关 IE 闪烁错误时,我还添加了这些元标记:
<meta http-equiv="Page-Enter" content="blendTrans(Duration=0.2)" />
<meta http-equiv="Page-Exit" content="blendTrans(Duration=0.2)" />
但这对我不起作用。
所以我添加了一张图片并通过这个css将它设置为不可见
.backgroundImageFix
{
width: 1%;
height: 1%;
opacity: 0.0
}
<asp:Image ID="Image1" runat="server" EnableTheming="True" ImageAlign="Bottom" CssClass="backgroundImageFix"
ImageUrl="~/Img/Besuchermanagement_1920_1080.jpg" />
现在我不再有任何闪烁问题。
但我不明白为什么添加图像会阻止背景图像在回发时重新加载。我希望任何人都可以向我解释一下,也许可以给我一个更好的解决方案。
最佳答案
在回发期间页面重新加载,因为它有一个生命周期,这使得页面重新加载,这是闪烁的 但要避免这种情况,您可以在 asp.net 中使用更新面板控件
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<asp:UpdatePanel id="UpdatePanel1" runat="server">
<ContentTemplate>
//your code here
</ContentTemplate>
</asp:UpdatePanel>
这应该可以阻止背景图像闪烁
关于css - asp .net 背景图像在回发时闪烁,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32842461/