我已经尽一切努力让图像显示为背景。我让它在我的本地 Visual Studio Express 安装上运行,但是当我上传到 Internet 主机服务器时,它不会正确呈现。我在标题背景图像上遇到了同样的问题,但找到了一个可行的解决方案,但同样的解决方案不适用于表单背景。
如果我在 中放置相同的背景图像样式标签 div class="page"
,它将在我的开发环境和 Internet 主机服务器上呈现,但我希望我的页面位于此图像之上(即我的应用程序代码页位于此背景图像之上。
有什么想法或建议吗?
Site.Master 代码片段
<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Site.master.cs" Inherits="MyApp.SiteMaster" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head runat="server">
<title><%=Page.Title %></title>
<link href="~/Styles/site.css" rel="stylesheet" type="text/css" />
<link id="Link1" runat="server" rel="shortcut icon" href="~/favicon.ico" type="image/x-icon"/>
<link id="Link2" runat="server" rel="icon" href="~/favicon.ico" type="image/ico"/>
<asp:ContentPlaceHolder ID="HeadContent" runat="server">
</asp:ContentPlaceHolder>
<style type="text/css">
.style1
{
text-align: center;
}
</style>
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
}
/* this code statement below is what I used to solve the header banner issue
but does not work for form background
*/
public string imgHeaderPath = System.Web.VirtualPathUtility.ToAbsolute("~/Images/water-banner.jpg");
</script>
</head>
<body >
<form runat="server" style="background-position: left top; background-repeat: repeat; background-attachment: fixed; background-image: url('/Images/willnotdisplay.jpg')">
<div class="page">
<div class="header" style="background-image: url('<%= imgHeaderPath %>')">
<div class="title">
<h1> <asp:Localize ID="Localize1" runat="server" Text="<%$ Resources:Resource, Title %>" /></h1>
</div>
.
.
.