可以在单个母版页中使用多个CSS文件 [英] Multiple CSS file can be used in a single Master page

查看:86
本文介绍了可以在单个母版页中使用多个CSS文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我想创建一个包含两个或多个CSS文件的母版页,所以问题是可以为单个母版页添加两个或多个CSS文件,如果是,那我该怎么做?

Hi,

I want create one master page who have two or more CSS file So, question is can its possible to add two or more CSS file for a single master page and if it''s YES then how can I do that?

How to associate those two file to that master page?

推荐答案

是的,您可以在母版页中添加多个CSS文件.
在标记中,您必须添加对css文件的引用,如下所示:
Yes, you can add multiple css files in master page.

In tag you have to add reference to the css file as follows :
<head>
   <link href="styles1.css" rel="stylesheet" type="text/css" /> 
   <link href="styles2.css" rel="stylesheet" type="text/css" />
</head>


为什么不将这样的内容添加到MasterPage标记中?

Why won''t you just add something like this to MasterPage markup?

<link type="text/css" href="<%=Page.ResolveClientUrl("~/css/Styles.css") %>" rel="Stylesheet" />



如果要从aspx页面控制css文件,只需添加内容控件:



If you want to control css files from aspx Pages just add content Control:

<head runat="server">
    <asp:ContentPlaceHolder runat="server" ID="pageHeadContent">
    </asp:ContentPlaceHolder>
</head>



并像这样从页面控制此内容占位符:



and control this content place holder from page like this:

<asp:Content ID="cwbHeadContent" ContentPlaceHolderID="pageHeadContent" runat="server">
    <link type="text/css" href="<%=Page.ResolveClientUrl("~/css/cwb.css") %>" rel="stylesheet" />
</asp:Content>



但是请记住不要在MasterPage AND Page的那个占位符中放置任何内容,否则会导致MasterPage中的内容消失.



But remember to NOT place anything in that placeholder in MasterPage AND Page, cause content in MasterPage just disapper.


这篇关于可以在单个母版页中使用多个CSS文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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