执行页面时,Asp.net C#主页面背景图像集不显示 [英] Asp.net C# master page background image set not appearing when the page is executed

查看:61
本文介绍了执行页面时,Asp.net C#主页面背景图像集不显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Microsoft Visual Studio中的C#在asp.net中设计一个网站。

我想在母版页中设置一个完整的背景图像,因此图像将出现在整个网站上内容页面的帮助。



我用

创建了一个带有以下代码的'Stylesheet.css'的页面

  html  
{
background url('Images\finalcollege.jpg')无重复中心固定;
}





注意:我使用的是CSS而不是CSS3。

我的软件版本Microsoft Visual Studio不支持CSS3



注意:图像与我的项目/网站位于同一文件夹中。



并在主页中使用以下代码链接外部样式表。



< head runat =   server >  
< title> < / title > ;
< link href = StyleSheet.css rel = < span class =code-string> stylesheet type = text / css />
< asp:ContentPlaceHolder id = head runat = server >
< / asp:ContentPlaceHolder >
< span class =code-keyword>< / head >





我甚至创建了母版页的内容页面..







现在问题是..当我在Visual Studio软件中完成所有这些编码时...当我点击内容页面的设计选项卡查看是否我的背景图片已经设置好了。我可以看到背景确实已经设置。

但是当我在浏览器中运行页面时,背景图像不会出现在浏览器中。



我尝试了什么:



我尝试多次刷新浏览器但无济于事..



与主页面链接的所有内容页面显示在Microsoft Visual Studio的设计视图中设置的背景图像



仅当我在浏览器中运行内容页面,不会出现背景图片。



请帮助

解决方案

确保



1)您提供的图像路径应该正确

2)使用 / 而不是 \ 在CSS的网址中



例如



背景:网址( '图像/ finalcollege.jpg')


I am designing a web site in asp.net with C# in Microsoft Visual Studio.
I want to set a full background image in the masterpage and hence the image will appear throughout the website with the help of contentpage.

I did it by
creating a css page 'Stylesheet.css' with the following code

 html
{
    background:url('Images\finalcollege.jpg') no-repeat center center fixed;
}



Note : I have used CSS and not CSS3.
My software version of Microsoft Visual Studio does not support CSS3

Note : The image is in the same folder as my Project/website.

and in the masterpage the following code to link the external stylesheet.

<head runat="server">
<title></title>   
    <link href="StyleSheet.css" rel="stylesheet" type="text/css" />
    <asp:ContentPlaceHolder id="head" runat="server">
    </asp:ContentPlaceHolder>
</head>



I have even created a content page of the master page..



Now the issue is..when i have done all of this coding in the Visual Studio Software.. when I click on the Design tab of the Content Page to see whether my Background image has been set. I can see that the background has indeed been set.
However when I run the page in browser.. the background image does not appear in the browser.

What I have tried:

I tried refreshing the browser many times but to no avail..

All the contentpages linked with the masterpage show background image being set in the design view of Microsoft Visual Studio

Only when i run the content page in the browser, the background image does not appear.

Please help

解决方案

Make sure

1) Image path which you are supplying should correct
2) Use / instead of \ in URL of css

e.g.

background:url('Images/finalcollege.jpg')


这篇关于执行页面时,Asp.net C#主页面背景图像集不显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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