如何在asp.net中将图像设置为背景 [英] how to set image as background in asp.net

查看:436
本文介绍了如何在asp.net中将图像设置为背景的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在asp.net中将图像设置为背景。我的代码如下所示。代码不完整只是为了包含将图像设置为背景的位置。

i want to set image as background in asp.net.here is my code below.the code is not complete just to include where to set image as background.

<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>

推荐答案

您无法引用通过Web服务器提供的css中的本地文件。 c:\ ......在这种情况下毫无意义。添加一个有意义的网址。例如,来自Web应用程序的静态图像的URL。
You can't refere to a local file in a css that is served via a web server. c:\... makes no sense in this context. Add an url that makes sense. For example an url to a static image from your web application.


创建CSS类并将该css类提供给body元素。它将起作用。



Create CSS class and give that css class to body element.It Will work.

<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>


您使用的路径不正确。

不要忘记确保将图像本身复制到解决方案的文件夹中





You are using an incorrect path.
Don't forget to make sure you copy the image itself to your solution's folder


<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>


这篇关于如何在asp.net中将图像设置为背景的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆