我有一个问题,它让我发疯。简而言之,我已经用纯 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 中无效。