简体   繁体   English

将背景图像添加到asp.net主网页asp.net 4.0和html5

[英]add background image to asp.net master web page asp.net 4.0 and html5

Using ASP.NET, C#, HTML5 and CSS3. 使用ASP.NET,C#,HTML5和CSS3。 My MasterPage is not recognizing the background image I have set in my stylesheet. 我的MasterPage无法识别我在样式表中设置的背景图像。 I found an answer from 2009 on the ASP.NET forums from an MSN developer and it is still not working. 我在MSN开发人员的ASP.NET论坛上找到了2009年的答案,但它仍然无法正常工作。 After checking the code, the answer is relevant to XHTML transitional, the default doctype for .NET in Visual Studio. 检查代码后,答案与XHTML过渡有关,这是Visual Studio中.NET的默认文档类型。

Any suggestions? 有什么建议么? Thank you in advance. 先感谢您。

<head runat="server">
    <title></title>
    <asp:ContentPlaceHolder id="head" runat="server">
    </asp:ContentPlaceHolder>

    <link href="../changes.css" rel="stylesheet" type="text/css" />
    <link href="../style.css" rel="stylesheet" type="text/css" />
    </head>
    <body>

    <form id="form1" runat="server">
    <div id="PageWrapper">


    html, body {
    background-color: #000;
    background-image: url('../images/darker_wood_1600x1200.jpg');
    background-attachment: scroll;
    background-repeat: repeat-x;
            }






    <!DOCTYPE html>
<html>
<meta charset="utf-8" />

<head><title>

</title>
<link href="changes.css" rel="stylesheet" type="text/css" /><link href="style.css" rel="stylesheet" type="text/css" /></head>
<body>

    <form method="post" action="Default.aspx" id="form1">
<div class="aspNetHidden">
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUKMTY1NDU2MTA1MmRkM1MGX8QufJ31wnSeINevDB81G3lHsitto4ucLAdg6zs=" />
</div>

    <div id="PageWrapper">

    <div id="Header"><a href="./">Header here
        </a></div>

    <div id="MenuWrapper">Menu here</div>

    <div id="MainContent">


    </div>

    <div id="Sidebar">Sidebar here</div>
    <div id="Footer">Footer here</div>
    </div>

</form>

This code works for me, but I don't know if the code above is how it looks. 这段代码对我有用,但是我不知道上面的代码是否看起来像。 Cause you post a stylesheet value in the middle of a div. 因为您将样式表值发布到div的中间。

Also, if the page can't read the file. 另外,如果页面无法读取文件。 Try a different file or try changing the search path for the file. 尝试使用其他文件或尝试更改文件的搜索路径。 Maybe it can't read it because it's outside the server dir. 也许因为它在服务器目录之外而无法读取它。 Because the CSS code looks correct. 因为CSS代码看起来正确。

<!DOCTYPE html>
<html>
<head runat="server">
    <title></title>
    <asp:ContentPlaceHolder id="head" runat="server">
    </asp:ContentPlaceHolder>

    <link href="../changes.css" rel="stylesheet" type="text/css" />
    <link href="../style.css" rel="stylesheet" type="text/css" />
    <link href="changes.css" rel="stylesheet" type="text/css" /><link href="style.css" rel="stylesheet" type="text/css" /></head>

    <meta charset="utf-8" />
    <style type="text/css">


        // If you want the "Page" background to be this way:
        html, body
        {
            background-color: #000;
            background-image: url('../images/darker_wood_1600x1200.jpg');
            background-attachment: scroll;
            background-repeat: repeat-x;
        }

        // Or the PageWrapper
        div#PageWrapper
        {
            background-color: #000;
            background-image: url('../images/darker_wood_1600x1200.jpg');
            background-attachment: scroll;
            background-repeat: repeat-x;
        }


    </style>
</head>
<body>
    <!--- <form id="form1" runat="server"> --->
    <form method="post" action="Default.aspx" id="form1">
        <div class="aspNetHidden">
            <input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUKMTY1NDU2MTA1MmRkM1MGX8QufJ31wnSeINevDB81G3lHsitto4ucLAdg6zs=" />
        </div>
        <div id="PageWrapper">

            <div id="Header">
                <a href="./">Header here</a>
            </div>
            <div id="MenuWrapper">
                Menu here
            </div>

            <div id="MainContent">
            </div>

            <div id="Sidebar">
                Sidebar here
            </div>
            <div id="Footer">
                Footer here
            </div>
        </div>
    </form>
    <!--- </form> --->
</body>
</html>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM