开发者

How do I set a picture as the background in ASP.NET?

I am unable to get the background picture to show in my pages. I am trying to do this in the master page using CSS.

I have a CSS which contains the following:

body {
    background-imag开发者_如何学编程e: url(../images/background.jpg) no-repeat;
    background-attachment: fixed;
    margin-top: 0px;
}

I know the CSS is being read because all other styles defined in it are working on the .aspx pages... except of course the background image, the background remains white. (This works perfectly fine in .php pages by the way.)

I have been searching online like crazy and all the answers I find, say the above CSS code is the answer... but it is not working!

I am using the following:

Microsoft Visual Studio 2008 Version 9.0.30729.1 SP

Microsoft .NET Framework Version 3.5 SP 1

Firefox Version 3.6.6

If anybody knows how to get this to work, PLEASE let me know!


The CSS background image technique is correct. But have you looked at things in a Http debugger (such as the net monitor in firebug or fiddler) and figured out if your relative pathing isn't screwing the proverbial pooch. Or, CSS paths and ASP.NET and MasterPages sometimes don't quite agree, you probably have an issue of requesting the image from the wrong url so it isn't showing up.


Thanks to Wyatt Barnett I was able to figure it out. I used firebug to edit the CSS file and discovered the problem.

  1. My path was wrong, I changed it from ../images/background.jpg --> ./images/background.jpg

  2. The attribute tag was wrong, I changed it from background-image --> background

I don't know why I did not think to do this with firebug to start with (it is after all why I have it) so thank you Wyatt for the proverbial slap upside the head - I needed it! :o)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜