[英]How can I target CSS to a particular sharepoint Page Layout file?
Is it possible to create a .CSS file for each SharePoint Page Layout I develop, or does the CSS for each possible layout in a master page need to be referenced in the master page? 是否可以为我开发的每个SharePoint页面布局创建.CSS文件,或者是否需要在母版页中引用母版页中每个可能布局的CSS?
IE is it possible to affect the <head>
of the page a page layout is used in? IE是否可以影响页面布局的页面
<head>
?
Michal's solution can be further enhanced by including any links etc in the PlaceHolderAdditionalPageHead content placeholder tag on your layout page. 通过在布局页面上的PlaceHolderAdditionalPageHead内容占位符标记中包含任何链接等,可以进一步增强Michal的解决方案。 This way it will be included properly in the head of the generated page.
这样,它将被正确地包含在生成的页面的头部中。
eg 例如
<asp:Content ContentPlaceholderID="PlaceHolderAdditionalPageHead" runat="server">
<link id="Link1" href="<% $SPUrl:~SiteCollection/Style Library/mystyle.css%>" runat="server" type="text/css" rel="stylesheet" />
<SharePoint:ScriptLink id="jQueryCore" language="javascript" name="ui.core.js" runat="server"/>
</asp:Content>
You can embed the CSS that you want to use in a Page Layout by putting in a tag in the page layout. 您可以通过在页面布局中添加标记来嵌入要在页面布局中使用的CSS。 For example:
例如:
<style type="text/css">
.ms-pagetitle, .ms-titlearea
{
margin-bottom: 5px;
}
</style>
Or in the page layout you can also create a relative link to the CSS file that you would like to use as well: 或者在页面布局中,您还可以创建您想要使用的CSS文件的相对链接:
<link rel="stylesheet" type="text/css" href="/_layouts/styles/mystyle.css"/>
In this way you can have different css styles overridden in the page layouts that you use. 通过这种方式,您可以在所使用的页面布局中覆盖不同的css样式。 Hope that helps!
希望有所帮助!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.