Resizing multiple SharePoint calendar overlay links

Outcome:overlaysbeforeafter.PNGIntro:

So you’ve made a SharePoint calendar. In fact, you’ve even made some different views for it and then made those views into overlays. Hoorah!

But now, looking at the finished product, the unevenness of the overlay links leaves something to be desired. This post will show you how to take your overlays and, in just a few minutes, turn them into a more polished look as seen above.

Let’s Do It:

If you have several pages you would like this change to be made on, I’d recommend going the master page route. Otherwise, for a single page or maybe just two, consider adding a Content Editor Web Part (CEWP) or script editor (see instructions further down).


Master Page Route (all pages)

Create multi-purpose custom .css file (or alter one you already have)

A. Find your Site Assets folder in SharePoint Designer. If you use a “Scripts” folder for your custom scripts, go there.

B. Since we’re editing the master page, I would recommend having just one css file that you include all the lines of adjustment to (not just from this solution, but any alterations you make that you intend to be reflected on all pages). This is literally one line of code we’re adding – you’ll likely collect several over time and it is easiest to reference and maintain one .css file that includes them all as opposed to several css files in the master page.

addcss.png

C. Add the following single line of css to your new or existing custom css file in SharePoint Designer. Adjust the width and alignment as necessary.

.ms-acal-apanel-item{width: 115px !important;text-align:center;}

D. Save your css file. In this example, I’ve renamed it custom.css.

Reference custom .css file in master page

E. Open a copy of your master page file for editing.

  1. In your browser, navigate to your site and go to Settings –> Site Settings
  2. Under Web Designer Galleries, select Master Pages
  3. “Download a copy” of seattle.master or oslo.master (whichever your site is using – if unsure, it’s likely seattle by default)
  4. Use Visual Basic or Notepad++ to open the downloaded file

F. Find the line just before the closing </head> tag and enter (assuming you also have a Scripts folder in Site Assets, otherwise omit that part):customcss

<SharePoint:CssRegistration Name="http://natethegreat.sharepoint.com/SiteAssets/Scripts/custom.css" runat="server" />

G. Save your master page file.

H. Upload your saved file to the master page gallery we just downloaded from. (Site Settings –> Master Pages) Make sure “Add as a new version to existing files” is checked so that you can always revert to a previous version easily if needed. Don’t change destination folder, but feel free to add a comment for a reminder such as “updated custom css file with calendar overlay links line” so you can easily see in the versions what you changed.

uploadmasterpage.png uploadmasterpage.png uploadmasterpage

And that’s all, folks! Go check your calendar. You should have beautifully uniform calendar overlay links to gaze upon.

overlaysbeforeafter.PNG


CEWP (one or few pages)

Create new .css file

A. Find your Site Assets folder in SharePoint Designer. If you use a “Scripts” folder for your custom scripts, go there.

B. Select Asset, then CSS.

addcss.png

C. Add the following single line of css to your new css file in SharePoint Designer. Adjust the width and alignment as necessary.

<style>
.ms-acal-apanel-item{width: 115px !important;text-align:center;}
</style>

D. Save and rename file whatever you like. In this example, I’m calling it calendaroverlay.css.

Call the new .css file from a CEWP

E. From the page on your site to which you want the change made, edit page and add a web part. (Settings icon –> edit page, then “Add a Webpart”).

addwebpartcalendar.pngF.  Under Categories, select “Media and Content” and then under Part select “Content Editor” and “Add”.

G. “Edit Web Part” (Note: do not “click here to add new…”).

H. Add the URL to your new css file ([SITE URL]/SiteAssets/Scripts/calendaroverlay.css) to the “content link” field and click “OK”.editwebpartcalendar2

I. From the ribbon’s page menu, select “stop editing.”

stopediting

That’s it! You should already see beautifully uniform calendar overlay links. Not too shabby, eh?

overlaysbeforeafter.PNG

7 Replies to “Resizing multiple SharePoint calendar overlay links”

  1. its not working after running Power BI as admin. any help?

    An error happened while reading data from the provider: ‘Could not load file or assembly ‘System.EnterpriseServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a’ or one of its dependencies. Either a required impersonation level was not provided, or the provided impersonation level is invalid. (Exception from HRESULT: 0x80070542)'”

  2. Thanks Nate! This was exactly what I was looking for. I had tried merging my data table with a date table which did the job but generated 33k rows versus this which resulted in 371 rows.

  3. this seems to work when in Edit page mode, but when I Stop editing/Save, the Attachment column just shows the paper clip. (In edit page mode, it shows the attachment name and is a link to open it).
    I’m using this with a Calendar web part.

  4. Is there a way to do this for hours between dates instead of “dates” between dates? So if i have a start and an end date…add a row for each hour in between the dates?

Leave a Reply to Nathan BrunnerCancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.