0

I have this index.aspx page that isn't loading graphics from the CSS. The text 'Test' is loading fine.

What am I doing wrong?

ASPX

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="index.aspx.cs" Inherits="chinatownexperience.index" %>

<!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">
    <title></title>
    <link href="css/main.css" rel="stylesheet" type="text/css" />
</head>
<body>
    <div id="body-1">
        <div id="topblank"><p>test</p>
        </div>
    </div>
    <form id="form1" runat="server">
    </form>
</body>
</html>

CSS:

html,
body {
    margin:0;
    padding:0;
    color:#000;
    background: #9c0000;
    background: url('images/Chinatown-lgebg.png') left top; 
}

#body-1 {
    width: 880px; height: 1500px;
    margin: 0px auto;
    padding: 10px;
    overflow:hidden; 
}

#topblank {
    float: left;
    width: 880px;
    height:266px;
    background: url('images/WebsiteTop.png') repeat-y left top;
}

I must be missing something silly?

2

3 Answers 3

1

for this examples u can addressing from root and dont use single cot like this

background:url(/yourProjectRoot/cssFolderNameOrFile.../yourImage.*)
Sign up to request clarification or add additional context in comments.

1 Comment

Are you suggesting putting the image in the CSS folder?
0

The path to the images must be relative to the location of the CSS file not the HTML/ASP/whatever file. You should point to the correct location of the images.

Example :

if you use directory structure like this :

- root\
|- css\
|- images\
page.extension

Then the path on the CSS file should be :

background: url('../images/whatever.png');

Comments

0

Your paths need to be relative to the stylesheet, not the root.

root 
  -css/styles.css
  -images/
  index.html

So if you had the above structure you would need this in your CSS

background: url('../images/your_image.png');

(worth noting that .htc files in CSS should have a path relative to the root. Handy for old browser fixes)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.