簡體   English   中英

如何將 CSS 文件添加到 ASPX(Sharepoint Online)

[英]How to add a CSS file to a ASPX (Sharepoint Online)

當我嘗試在站點頁面中編輯 my.aspx 頁面時,我無法讓它加載我的自定義 CSS 文件。

Sharepoint 2013 強制我將.aspx 作為高級文件打開,否則我無法編輯它。

然后文件如下所示

<%@ Page language="C#" Inherits="Microsoft.SharePoint.WebControls.ClientSidePage, Microsoft.SharePoint, Version=16.0.0.0, Culture=neutral, PublicKeyToken=#######" %><%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=16.0.0.0, Culture=neutral, PublicKeyToken=#######" %>
<html xmlns:mso="urn:schemas-microsoft-com:office:office" xmlns:msdt="uuid:######"><head>
<meta name="WebPartPageExpansion" content="full" />
<!--[if gte mso 9]>
<SharePoint:CTFieldRefs runat=server Prefix="mso:" FieldList="FileLeafRef,ClientSideApplicationId,PageLayoutType,CanvasContent1,BannerImageUrl,BannerImageOffset,PromotedState,FirstPublishedDate,LayoutWebpartsContent,_TopicHeader,_SPSitePageFlags"><xml>
    
    
    
        
    
    
<mso:CustomDocumentProperties>
<mso:PageLayoutType msdt:dt="string">Article</mso:PageLayoutType>
<mso:_SPSitePageFlags msdt:dt="string"></mso:_SPSitePageFlags>
<mso:CanvasContent1 msdt:dt="string">PAGE CONTENT</mso:LayoutWebpartsContent>
<mso:_AuthorByline msdt:dt="string"></mso:_AuthorByline>
<mso:display_urn_x003a_schemas-microsoft-com_x003a_office_x003a_office_x0023__AuthorByline msdt:dt="string">NAME</mso:display_urn_x003a_schemas-microsoft-com_x003a_office_x003a_office_x0023__AuthorByline>
</mso:CustomDocumentProperties>
</xml></SharePoint:CTFieldRefs><![endif]-->
<title>SITE TITLE</title>
</head>

然后我在頭部添加了<link rel="stylesheet" href="SITEURL/StylesSheetNew.css">

當我查看頁面時,CSS 沒有加載,我已經准備好很多資源並且正在撞牆,我做錯了什么?

您可以使用 SPFX 擴展將 js/CSS 注入 SharePoint 在線現代頁面。
演示: https://github.com/hugoabernier/react-application-injectcss 在此處輸入圖像描述 在此處輸入圖像描述

您是在使用 Sharepoint Online(您的 Title)還是 Sharepoint 2013 on-premise(您的描述)?

對於 sharepoint 在線 - 不支持插入 css 或 JavaScript。 您可以使用:

  1. 應用程序定制器擴展。 例如: https://tahoeninjas.blog/2018/05/08/inject-custom-css-on-sharepoint-modern-pages-using-spfx-extensions/
  2. 現代腳本編輯器 - https://github.com/pnp/sp-dev-fx-webparts/tree/master/samples/react-script-editor 安裝它,將其添加到頁面中,您可以通過<style>標簽添加 CSS 樣式

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM