CSS和主页上的图像 [英] CSS and images on Master Page

查看:258
本文介绍了CSS和主页上的图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个相当普遍的问题,但没有找到一个工作的解决方案。



基本上,我使用一个主页面(/Masterpages/Default.master ),包括

 < link href =../ css / style.css =stylesheettype = text / css /> 

还包括一些具有相同相对链接的图片。 p>

但是当我将母版页应用于内容页面时(在不同的文件夹级别),css格式和图像会丢失。





提前感谢



UPDATE:



还有一个额外的问题,很难得到输出在浏览器和在Visual Studio中设计视图。



我使用 asp:image 解决方案来处理母版页中的图像,

 

code>< link href =../ css / style.css =stylesheettype =text / css/>
< link href =<%= ResolveUrl(〜/ css / style.css)%> rel =stylesheettype =text / css/>


解决方案

最好使用:

 < link href =<%= ResolveUrl(〜/ css / style.css)%> rel =stylesheettype =text / css /> 

根不同:

 < link href =/ css / style.css =stylesheettype = css /> 


I have this quite popular problem, but have failed to find a solution that works.

Basicly, I am using a Master Page (/Masterpages/Default.master), that includes

<link href="../css/style.css" rel="stylesheet" type="text/css />

And it also includes some images with the same relative linking.

But when I apply the Master Page to content pages (in diffrent folderlevels) the css formating and images is lost.

Is there anyway to dynamicaly solve the folderlevel links to css and images to all content pages using the masterpage?

Thanks in advance

UPDATE:

There is an additional problem. It's tricky to get the output to render correctly in both the browser and in design view in Visual Studio.

I got it to work by using the asp:image solution for the images in the masterpage and by double linking the css in the masterpage, one to make it render in VS and one to make it render correctly browsing the site.

<link href="../css/style.css" rel="stylesheet" type="text/css" />
<link href="<%=ResolveUrl("~/css/style.css")%>" rel="stylesheet" type="text/css" />

解决方案

best to use:

<link href="<%=ResolveUrl("~/css/style.css") %>" rel="stylesheet" type="text/css />

since this will cope with iis application roots unlike:

<link href="/css/style.css" rel="stylesheet" type="text/css />

这篇关于CSS和主页上的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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