p1
{
    background-image:url(F:\image\1.jpg);
}
.p2
{
    background-image:url(F:\image\2.jpg);
}<table class="style1" style="background-image:url(F:\image\guanli_01.jpg)">
    <tr>
        <td class="style7" rowspan="2">
        </td>
        <td class="style5" colspan="2">
        </td>
        <td class="style2" rowspan="2" style="width:24px">
        </td>
    </tr>
    <tr>
        <td class="style6" style="width:88px"><asp:Button ID="button1" runat="server"  
                Width="88px" Height="26px" class="p1" onclick="button1_Click" /></td>
        <td style="width:88px"><asp:Button ID="button2" runat="server" Width="88px" 
                Height="26px"  class="p2" onclick="button2_Click"/></td>
    </tr>
</table>上面的这个表格,在设计视图中能显示背景图片,为什么浏览器中运行就显示不出?
其中两个按钮的背景也是如此。希望高手解答

解决方案 »

  1.   

    样式别这么写,你项目换地址就不行了p1
    {
      background-image:url(..\image\1.jpg);
    }
    .p2
    {
      background-image:url(..\image\2.jpg);

      

  2.   


    <tr>
      <td class="style6" style="width:88px"><asp:Button ID="button1" runat="server"   
      Width="88px" Height="26px" CssClass="p1" onclick="button1_Click" /></td>
      <td style="width:88px"><asp:Button ID="button2" runat="server" Width="88px"  
      Height="26px" CssClass="p2" onclick="button2_Click"/></td>
      </tr> 
    红色部分试一下
      

  3.   

    CssClass
      

  4.   

    关键是 那个F:\  ,你这个定位,实际上会定位到客户端的f:, 比如你做的网站,小王在家里用,他访问这个网页时就会查找小王机器上的f:\的图片,怎么可能查得到呢!改成http:// 这样的完整路径,或者 /这样的相对路径即可. 
      

  5.   

    你写的很不规范 ! 代码很乱!!控件按钮在控件属性里就有的!简单的设置可以,但是最好用script写。 
      

  6.   

    ----- 本地设计视图,可以找到PC上的图片路径,但网站发布后:       1、如果使用绝对路径,那么可以类似这样编码     <table class="style1" style="background-image:url(http://image/guanli_01.jpg)">
          2、如果使用相对路径,那么可以类似这样编码     <table class="style1" style="background-image:url(../image/guanli_01.jpg)">根据你的具体情况,建议使用第二种方法~~~~      还有一个问题,即使你按上述方法改了,有可能还是看不到,因为你虽然有了表格,但无内容,所以表格占用的地方很小,所以图片不能显示,或显示的很小以部分,你可以在表格中填点内容,再看看就可以了,比如:<table class="style1" style="background-image:url(C:\美洲地图.gif)">
      <tr>
      <td class="style7" rowspan="2">
       asdf
      </td>
      <td class="style5" colspan="2">
       asdfasdf
      </td>
      <td class="style2" rowspan="2" style="width:24px">
       asdfasdf
      </td>
      </tr>
      <tr>
      <td class="style6" style="width:88px"><asp:Button ID="button1" runat="server"   
      Width="88px" Height="26px" class="p1" onclick="button1_Click" />
      asdfasdfasdf
      </td>
      <td style="width:88px"><asp:Button ID="button2" runat="server" Width="88px"  
      Height="26px" class="p2" onclick="button2_Click"/>
      asfdasdfa
      </td>
      </tr>
    </table>
      

  7.   

    不要带盘符的。你写相对路径或绝对路径就行了,CSS单独写,图片要是跟CSS文件在一个文件夹里面,路径都不需要的,有个文件名就行了。