主页面图片没有显示在内容页面?

时间:2022-01-31 21:13:07

I have a master page with one div Header.

我有一个带有一个div标题的主页。

#header
        {
             background-image: url("images/ST_ERP_2.jpg");
            background-repeat: no-repeat;
            background-position: right top;

            height: 200px;
            width: 1200px;
        } 

below is the header div

下面是header div

<div id="header" >
            <h1>
                Header goes here</h1>               
</div> 

Both the above code snippents are in my master page.

上面的代码剪切都在我的主页中。

Now I have a content page (xyz.aspx) which is inside some directory.

现在我有一个内容页(xyz.aspx),它在某个目录中。

The image (ST_ERP_2.jpg) is in the images folder.

图像(ST_ERP_2.jpg)在images文件夹中。

Now when I try to view the page (xyz.aspx) in a browser it doesn't show me the image which I have set for background-image instead it shows me a blank white area. What could be the problem?

现在,当我试图在浏览器中查看页面(xyz.aspx)时,它不会显示我为背景图像设置的图像,而是显示一个空白的白色区域。有什么问题呢?

NOTE:

注意:

  1. I have also tried background-image: url("~/images/ST_ERP_2.jpg"); but it doesn't help me.

    我也尝试过背景图像:url(“~/images/ST_ERP_2.jpg”);但这对我没有帮助。

  2. I am using VS2010 and ASP.NET

    我正在使用VS2010和ASP.NET

MASTER PAGE:

主页:

<%@ Master Language="C#" AutoEventWireup="true" CodeFile="Site.master.cs" Inherits="Site" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajax" %>
<%--<%@ Register Assembly="AccordionSiteMap" Namespace="FranchiseBlast.UserControls.Interface"
    TagPrefix="lb" %>--%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">

    <style type="text/css">

        #wrapper
        {
            background: #FFFFFF;
            margin: 0px auto;
            width: 1200px;
            height: 1024px;
        }

        #header
        {
             background-image: url("images/ST_ERP_2.jpg");
            background-repeat: no-repeat;
            background-position: right top;

            height: 200px;
            width: 1200px;
        }

        #footer
        {
            background: #838283;
            height: 40px;
            width: 1200px;
            margin: 600px 0px;
        }
    </style>
    <title></title>
</head>
<body style="background: LightBlue">
    <form id="form1" runat="server">
    <div id="wrapper">
        <div id="header" >
            <h1>
                Header goes here</h1>
            <br />

        </div>
        <!--Header-->


 .... content place holder and etc  ......


         <div id="footer" style="clear: both">
            <h3>
                Footer goes here</h3>
        </div>
        <!--Footer-->
    </div>
    </form>
</body>
</html>

2 个解决方案

#1


3  

Try replacing the background-image with this:

试着用以下方法替换背景图像:

background-image: url(<%=ResolveClientUrl("~/images/ST_ERP_2.jpg")%>);

#2


0  

Try:

试一试:

background-image: url("../images/ST_ERP_2.jpg");

#1


3  

Try replacing the background-image with this:

试着用以下方法替换背景图像:

background-image: url(<%=ResolveClientUrl("~/images/ST_ERP_2.jpg")%>);

#2


0  

Try:

试一试:

background-image: url("../images/ST_ERP_2.jpg");