簡體   English   中英

HTML背景圖片未顯示

[英]Html Background Image not showing

我在Visual Studios中制作了一個網站。 我試圖改變我網站的背景。 當我在Visual Studios中添加圖像時,它會更改,但是當我啟動它以在Web瀏覽器中查看它時,背景圖像就消失了。

'<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
    .auto-style1 {
        width: 100%;
    }
    h1{
       text-align:center;
       font-family:Andalus;
       color:white;

   }
  body{
      background-image: url('C:\Users\........\Desktop\wood.jpg');
      text-align:center;
  }

    .auto-style2 {
        width: 664px;
    }
    p{
        font-family:Cambria;
        color:white;
    }

</style>
</head>
<body>

<form id="form1" runat="server">
<div>
<h1> Welcome</h1> 
  </div>
    <table class="auto-style1">
        <tr>
            <td class="auto-style2"><p>Username</p></td>
            <td class="auto-style2"><asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
            </td>
            <td class="auto-style2">&nbsp;</td>
            <td>
                &nbsp;</td>
        </tr>
        <tr>
            <td class="auto-style2">
                <p>Password</p></td>
            <td class="auto-style2">
                <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
            </td>
            <td class="auto-style2">
                &nbsp;</td>
            <td>
                &nbsp;</td>
        </tr>
        <tr>
            <td class="auto-style2">
                &nbsp;</td>
            <td class="auto-style2">
                <asp:Button ID="Login" runat="server" OnClick="Login_Click" Text="Log in " />
                </td>
            <td class="auto-style2">
                &nbsp;</td>
            <td>
                <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Log in as guest" />
            </td>
        </tr>
    </table>
    <asp:Label ID="Label1"  runat="server"></asp:Label>
</form>

如果您要引用桌面上的圖像,聽起來好像沒有設置項目文件夾。 您還在代碼中使用了絕對值,因此根據您上載網站的方式,這可能會導致問題。 我不熟悉Visual Studio上載內容的方式。

創建一個新的項目文件夾,然后創建一個名為images或諸如此類的子文件夾,並通過如下方式引用它們:

  body{
      background-image: url('/images/wood.jpg');
      text-align:center;
  }

在這里查看: http//www.w3schools.com/html/html_images.asp,以獲得更多提示。

如果仍然有問題,請通過從瀏覽器(而不是程序)查看源代碼來將代碼粘貼到此處,這可能會給您一些提示。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM