我有个问题,快把我逼疯了。简而言之,我已经在纯HTML/CSS中本地测试了subj中的方法,它工作得很好:
<html style="
padding:0px;
border:0px;
margin:0px">
<body style="padding:0px;border:0px;margin:0px;">
<form style="width:100%;height:100%;padding:0px;border:0px;margin:0px;background: url(background.jpg) no-repeat fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='background.jpg', sizingMethod='scale');
-ms-filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='background.jpg', sizingMethod='scale');">
<div style="float:right;width:500px;height:100%;background-color:#ffffff;padding:0px;border:0px;margin:0px;"></div>
</form>
</body>
</html>
但是试图把它放在ASP。Net完全失败了,因为图像没有调整大小,而是以固有大小显示。
<body>
<form id="MainForm" runat="server" style="height:100%;width:100%">
<div class="MainArea" runat="server">
<div class="Header">
<asp:Label ID="PageTitleLabel" runat="server"></asp:Label>
</div>
<%
string logoPath =
System.Web.Configuration.WebConfigurationManager.AppSettings[ "logo" ];
if( !String.IsNullOrEmpty( logoPath ) )
{
%>
<div class="GroupXLargeMargin">
<img src="<%= logoPath %>" alt="logo" />
</div>
<%
}
%>
<div class="GroupLargeMargin">
<div class="TextSizeXLarge">
<asp:Label ID="STSLabel" runat="server"></asp:Label>
</div>
</div>
<div class="MainActionContainer">
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</div>
</div>
</form>
</body>
CSS: 和
*
{
margin: 0px;
}
html, body
{
width: 100%;
height: 100%;
padding: 0px;
}
body
{
font-size: 0.8em;
font-weight: normal;
font-family: "Segoe UI", Verdana, Tahoma, Arial, sans-serif;
background-color: #ff5500;
color: #222222;
background: url(../App_Themes/Default/background.jpg) no-repeat;
background-size: cover;
-o-background-size: cover;
-webkit-background-size: cover;
-moz-background-size: cover;
filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='../App_Themes/Default/background.jpg', sizingMethod='scale');
-ms-filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='../App_Themes/Default/background.jpg', sizingMethod='scale');
}
我看不出它不工作的理由,但它没有。ASP页面是ADFS登录母版页面,如果这很重要的话。我尝试过将背景应用于各种元素,它总是相同的-在HTML中工作,在ASP.Net中不工作。
好吧,看来我不得不把它贴出来让自己想得更好:)这一切都归结为母版页本身的一条语句:
<meta http-equiv="X-UA-Compatible" content="IE=8" />
注释出来,它就可以工作了。