设置背景图片在asp.net中(主页) [英] Setting background image in asp.net (Master page)

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

问题描述

我是新的asp.net。而我无法设置我的背景图片。这里的主网页源代码:

I'm new in asp.net. And I am having trouble setting my background image. Here's the master page source:

<%@ Master Language="C#" AutoEventWireup="true" CodeFile="Master.master.cs" Inherits="Master"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <link rel="stylesheet" type="text/css" href="scripts/style.css"/>
    <title>Tracker</title>
    <asp:ContentPlaceHolder id="head" runat="server">
    </asp:ContentPlaceHolder>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <div class="container">
                <a href="#"><img src="images/cross-header.gif" alt="Insert Logo Here" width="100%" id="Insert_logo" style="background: #C6D580; display:block;" /></a>

            <div class="sidebar1">
                <nav>
                    <ul>
                        <li><a href="#">Home</a></li>
                        <li><a href="#">LINK</a></li>
                        <li><a href="#">LINK</a></li>
                        <li><a href="#"><span style="font-weight:italic">LINK</span></a></li>
                        <li><a href="#"><span style="font-weight:italic">LINK</span></a></li>
                    </ul>
                </nav>
                    <p>SOME LABEL</p>
                    <p>SOME QUOTE HERE</p>
                    <p></p>
            </div>
        </div>
        <footer>
           <a href="#">LINK HERE</a> | <a href="#">LINK HERE</a> | 
           <a href="contact.php">CONTACT</a> | <a href="register.php">REGISTER</a> | <a href="login.php">LOGIN</a>
            <address>
                Copyright 2012 @JRC
            </address>
        </footer>
    </div>
    </form>
</body>
</html>

这是我想使用的图像位于该文件夹的图像。我不知道什么是错。

The image that I am trying to use is located at the folder image. I don't know whats wrong.

和这里的什么的style.css源:

And here's what the style.css source:

body 
{
    font: 100%/1.4 Verdana, Arial, Helvetica, sans-serif;
    margin: 0;
    padding: 0;

    background-image:url('images/background.jpg');
    background-repeat:no-repeat;
    background-attachment:scroll;
    background-position:repeat-x;
}

我也试过这个网址(图像/ background.jpeg)等,但仍然失败。

I also tried this url('image/background.jpeg') etc. but still fails.

推荐答案

这在很大程度上取决于在您的CSS文件的位置。如果位于同一文件夹中的图像文件夹的位置,那么这看起来是正确的。但是,如果你的CSS文件在不同的目录(比如/ CSS),那么你在你的CSS文件的链接将无法正常工作。相反,无论是更改CSS链接指向一个完整的链接:

This largely depends on where your css file is located. If it is located in the same folder where the 'image' folder is located, then this looks correct. However, if you css file is in a different directory (say /css) then your link in your css file will not work. Instead, either change the css link to point to a complete link:

background-image: url('http://mysite.com/images/background.jpg)

我不确定如果'〜'链接将工作在一个样式表。因为你的CSS是在脚本文件夹,你应该能够做到这一点:

I am unsure if the '~' link will work in a stylesheet. Since your css is in the scripts folder, you should be able to do this:

background-image: url('../images/background.jpg')

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

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