Hot answers tagged

11

I know exactly what you're looking for. While a debate about proper link tag usage and CSS storage folders is always a fun topic, realize none of that is your issue here. There are two components that allows you to add <link> tags to Page Layouts. First, you need to find the following lines of code in the head of the Page Layout's HTML page: ...


9

This issue caused by angle brackets "<" to fix it replace it with "&lt" as below: <!--SPM:<SharePoint:CssRegistration name="&lt;% $SPUrl:~sitecollection/_catalogs/masterpage/css/style.css %&gt;" runat="server" />-->


6

I'm sure there is room for improvement, but here is a working sample. jQuery(document).ready(function () { //narrow down matching to dialog boxes only if(location.href.indexOf('IsDlg=1') !== -1) { $(".ms-dialog td.ms-formbody > span > table > tbody > tr:first-child > td > span.ms-RadioText").each(function(){ ...


5

Try adding the path, as you have done in Name also, in After. Or since you have the css files directly in the 15, remove the path from the Name property. First option: <SharePoint:CssRegistration runat="server" ID="Custom2" Name="/_layouts/15/Custom2.css" After="/_layouts/15/Custom1.css" /> Second option <SharePoint:CssRegistration ...


5

I would advise against this...I would also advise against having an exact copy of the coreV4.css file. Having both these files is going to beef up the load times and increase the needless amount of code the browsers need to go through. Change your CSS registration to the following line. I also always add it after the CoreV4.css not that it makes a ...


4

I've also observed what you have; beyond ensuring that your CSS comes after core.css/corev4.css, the CSSRegistration.After property plainly doesn't work. I've extensively tested CssRegistration by using it to link 10 different CSS files into one user control, and it completely ignored the dependencies I specified. Furthermore, the ordering seems completely ...


4

As you say, there is no media attribute. There are a couple of ways I can think of to handle this in SharePoint: Either use Device Channels to target different master pages to different devices Or, add all of your responsive CSS to one file, containing the @media wrappers. This will also be better since if you for example resize your browser window, you ...


4

Thanks for Tiago for providing the solution. So here is the code if you want to move description up for Multiple lines of text. $("td.ms-formbody > span > textarea.ms-long").each(function(){ var descriptionElement = $(this).closest('.ms-formbody').contents().filter(function(){ return this.nodeType != 1; }); var descriptionText = ...


4

You have to change the file path like if you want to refer from 15 hive, <SharePoint:CssRegistration name="/_layouts/15/mycompany/develop/styles/style.css" runat="server" after="SharepointCssFile"/> It would not cause any issues if you refer it from 14 hive. But it would be better if you move it to 15 hive as all other stuffs related to Sharepoint ...


3

try <SharePoint:CSSRegistration ID="CSSReg5" name="<%$SPUrl:~SiteCollection/Style Library/CSS/styles.css%>" After="corev4.css" runat="server"/> the part <%$SPUrl:~SiteCollection points to the root site collection, maybe your code is not pointing to that location! rather the site or sub site, method above explicitly says root site collection ...


3

The above answer is not right. It is totally unnecessary to touch corev15.css. These are the steps to apply custom CSS to SharePoint site hosted at Office 365. Find "Site Collection Features" setting and enable all features with name "publishing" in it. Find "Manage Site Features" setting and enable all feature with name "publishing" in it. Find "Master ...


3

If you don't want to modify the master page, then the alternative is to go into Site Settings and click on Master Page in the look and feel section and in there add your custom css file into the Alternate CSS URL section.


3

Another method to add the CSS is to create the CssRegistration object in the C# codebehind for the web part, and add your instance of CssRegistration to the web part's control hierarchy using this.ChildControls.Add(). You'll need to ensure this code is done within CreateChildControls override of the web part.


3

URLs in CSS files are always relative to the CSS file itself. If you have assets to reference that are in the same (or close) location (for example, in Style Library or similar), you can simply use paths relative to the CSS file. If you are referencing assets from within _layouts or _layouts/images, that's just as easy. These are configured as virtual ...


3

If it is SharePoint List form, you can simply make the fields as Required and SharePoint will handle it... But if its some other form, which I think it is... you can use JavaScript like this: <script type="text/javascript"> function onSubmitValidation() { if (TrimAll(document.getElementById("field1").value) == "") { alert('All fields are ...


3

To do this properly, leave corev4.css alone and define your own custom CSS file that includes only the CSS classes that you want to override. CSS loads in order so as long as your custom CSS is loaded after corev4, your styles will be applied. Since your new file includes only the CSS classes that were modified, it will also be much easier to manage than ...


2

i dont think your doing it properly! <SharePoint:CssRegistration Name="<%$SPrl:~sitecollection/Style Library/MyCustomTheme/mycss.css%>" runat="server" After="corev15.css"/> you were doing "<% $SPUrl=~ instead of "<%$SPrl:~ http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.webcontrols.cssregistration.aspx EDIT try ...


2

I have a lot of success adding CSS to a page by using the Script Editor web part (Found in Media and Content). Place the web part, edit it and copy your CSS link or the CSS itself and save the page. I have been using it to style some in-page controls for Excel Services Web Parts.


2

recently we had the same probleme with our site which should open in IE8 document mode. Whenever we set to display IE8 mode no changes! To fix this we had modified web.config file and added these lines <configuration> <system.webServer> <httpProtocol> <customHeaders> <clear /> <add ...


2

You can use ConditionalExpression property to specify your conditional browser version. For ex. <SharePoint:CSSRegistration name="/_layouts/solutionfolder/filename.css" After="corev4.css" ConditionalExpression="lt IE 7" runat="server" />


2

Check in and publish as major version the masterpage


2

As a best practice, please make a copy of your seattle and oslo master pages. Change your site to inherit from your copy of seattle/oslo master page. In my case, I opened the custommaster.html and inserted the below CSS line <!--SPM:<SharePoint:CssRegistration name="&#60;% $SPUrl:~sitecollection/Style Library/custom.css %&#62;" ...


2

I had the same issue and as you said none of the CSS of Script did work for me as well. So I have to patch something with below script. This should be considered as a last option if you have any other solution available. So if you try this, you will have your issue fixed with below script: var interval = null; //Defines the start interval variable ...


1

CSS has a hierarchy of applying. First CSS from external files, then CSS inside the file and at highest priority the inline CSS. So you could tryout inline or CSS inside the file with the !important tag.


1

If you just want to add custom CSS to a specific page, then add a Content Editor web part and point that to your CSS file.


1

This works fine for me, in the html master file : <!--SPM:<SharePoint:CssRegistration ID="CustomCSS" name="&#60;% $SPUrl:~SiteCollection/_catalogs/masterpage/css/custom.css%&#62;" After="corev15.css" runat="server"/>-->


1

If you don't want to edit master pages or page layouts I usually store the CSS in a document library (or asset library) on the same SharePoint site. Then I add content editor web part (CEWP) to the page to 'insert' this css into the page. Disadvantage is that you need to add that CEWP to every page where you want to apply the styling. I have once written ...


1

A very effective and easy way is to store the css files either in the file system or in the style library(I vote for the first one). First create a css file with the style definitions you want and save it in the structure in Visual Studio of a SharePoint Project. The files could either be copied to SharePoint root or to a SharePoint library on deployment. ...


1

It seems that the problem arise when your master pages are not located in the Master Page Gallery. The problem went away when I added the master page to the master page gallery and referenced it from there (i.e. _catalog/masterpage/mymasterpage.master) instead of the _layouts folder. The actual server deployment location of the master page is still in the ...


1

I had a similar issue with a custom Master Page I created in Design Manager. To fix, I created a new Minimal Master Page from scratch, tested that the datepicker worked, then copied my HTML and Style Sheets to the new Master Page.



Only top voted, non community-wiki answers of a minimum length are eligible