【解決方法】asp.netで画像を背景として設定する方法


asp.net.here で背景として画像を設定したいです。以下は私のコードです。コードは、画像を背景として設定する場所を含めるだけでは完全ではありません。

XML
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>BELLCONSULTS</title>
    <style type="text/css">
     .mn{text-decoration:none}
     #hd{background-image:url(C:\Users\BELLCONSULT\Desktop\bellweb\bellimage\BANNER1.jpg);}

    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <table style="width:1200px; margin-left:100px; border-style:none">
            <tr>
                <td id="hd"  colspan="3" style="height:110px">

              </td>
            </tr>
            <tr>

解決策 1

Web サーバー経由で提供される CSS でローカル ファイルを参照することはできません。 c:\… は、このコンテキストでは意味がありません。 意味のある URL を追加します。 たとえば、Web アプリケーションからの静的画像への URL です。

解決策 2

CSS クラスを作成し、その CSS クラスを body 要素に付与します。

XML
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>BELLCONSULTS</title>
    <style type="text/css">

 .body
{
background:url("C:\Users\BELLCONSULT\Desktop\bellweb\bellimage\BANNER1.jpg");
background-repeat:no-repeat;
}
    </style>
</head>
<body class="body">;
    <form id="form1" runat="server">
    <div>
        <table style="width:1200px; margin-left:100px; border-style:none">
            <tr>
                <td id="hd"  colspan="3" style="height:110px">

              </td>
            </tr>
            <tr>

解決策 3

間違ったパスを使用しています。
画像自体を解決策のフォルダーにコピーすることを忘れないでください

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>BELLCONSULTS</title>
    <style type="text/css">
     .mn{text-decoration:none}
     #hd{"background-image:url(header.jpg);}

    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <table style="width:1200px; margin-left:100px; border-style:none">
            <tr>
                <td id="hd"  colspan="3" style="height:110px">
 
              </td>
            </tr>
            <tr>

コメント

タイトルとURLをコピーしました