本文介绍了SharePoint Foundation 2013 - 链接网站集中的 CSS 文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在母版页中链接我的 css 文件时遇到问题.

I ran into an issue with linking my css files in master page.

<SharePoint:CssRegistration ID="StyleSheet1" Name="~sitecollection/_catalogs/masterpage/Resources/css/quack_1200.css" After="corev15.css" runat="server" />
    <SharePoint:CssRegistration ID="StyleSheet2" Name="~sitecollection/_catalogs/masterpage/Resources/css/main.css" After="corev15.css" runat="server" />

这些文件没有被加载.当我在浏览器中访问控制台时,它不会显示任何错误,当我调查 HTML 时,它不会显示 CSS 文件.

These files are not being loaded. When I access the console in browser it doesn't show any errors and when I investigate the HTML it does not show the CSS files.

但是,如果我访问 URL 上的文件,它们确实存在.这是部署 XML 定义.

However if I access the files on the URL they do exist.This is the deployment XML definition.

<File Path="Resources\css\main.css" Url="masterpage/Resources/css/main.css" IgnoreIfAlreadyExists="TRUE" Type="GhostableInLibrary" />
<File Path="Resources\css\quack_1200.css" Url="masterpage/Resources/css/quack_1200.css" IgnoreIfAlreadyExists="TRUE" Type="GhostableInLibrary" />

如果我输入整个 URL,我就可以访问这些文件.

If I type the whole URL I am able to access the files.

http://[电脑名称]/sites/PCF/_catalogs/masterpage/Resources/css/quack_1200.csshttp://[电脑名称]/sites/PCF/_catalogs/masterpage/Resources/css/main.css

你能帮我解决这个问题吗.

Could you please help me on resolving this issue.

谢谢

推荐答案

问题在于 CssRegistration 不处理 ~sitecollection 令牌.

The problem is that CssRegistration doesnt handle the ~sitecollection token.

我还没有测试过,但尝试添加:

I havent tested this, but try to add:

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

如果您不知道如何建立您的网址,您可以随时使用 javascript/jQuery 添加 css 文件.

If you cant figure out how to build up your url, you could always add the css files with javascript / jQuery.

var linkTag = '<link href="' + _spPageContextInfo.siteAbsoluteUrl + '/_catalogs/masterpage/Resources/css/quack_1200.css" rel="stylesheet" type="text/css"/>';
$(document).ready($('head').append(linkTag);

这篇关于SharePoint Foundation 2013 - 链接网站集中的 CSS 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 02:12
查看更多