Category Archives: HTML/CSS

Obscure issue with moving around items in SharePoint 2013 ribbon

Ever have one of those days where SharePoint just makes you say, umm, WTF??? Yeah, me too. Tag another one on the long list.

I wanted to absolute position the ribbon’s tab row right DIV contents of SharePoint 2013 to a different location on the page. In non-SharePointy code speak, I just wanted to move the links on the right side of the page that consist of Share, Follow, Edit/Save, Focus on Content and Developer Dashboard to a different place on the web page.

Links and icons in tab row right of the SharePoint 2013 ribbon

Seems easy, right? SharePoint 2013 laughed in my face.

These links and icons are child elements of a DIV that is part of a trio of elements that makes up the SharePoint ribbon. Essentially the ribbon is an unordered list sandwiched between two DIVs that each provide a peripheral area where you can stick other stuff. The links and icons are in the right DIV, aptly named through the ID RibbonContainer-TabRowRight. It also has a few classes assigned to it, one of which is ms-cui-TabRowRight.

Based on the available code in the page, my CSS started as this:

.ms-cui-TabRowRight {
     position: absolute;

I don’t have to go any farther than that to create an issue:

Issues created after modifications

The ribbon tabs collapse. And the whole set of links/icons that I was targeting disappeared from the page. Upon further investigation two things emerged:

  1. The inline style for display was changed to display: none in the .ms-cui-TabRowRight DIV.
  2. A different CSS class is applied to the parent UL that wraps the ribbon tabs, .ms-cui-tts-scale-2. It was previously .ms-cui-tts. The presence of this little class then kicks in the following style statement, found in corev15.css:
    .ms-cui-tts-scale-2 .ms-cui-tt-a {
         overflow: hidden;
         width: 20px;

The 20 pixel width explains the tiny ribbon tab slivers you see in the screenshot above.

If you take away the absolute positioning or just do something as tame as changing it from absolute to relative, then the inline style goes back to display: block and the applied CSS class for the UL switches back to .ms-cui-tts.

OK so maybe it was the absolute positioning… when you move elements like that things can go wonky. So I switched it to a float (keep in mind this DIV is floated by SharePoint in the first place):

.ms-cui-TabRowRight {
     float: left;

Floating the links and icons in tab row right of the SharePoint 2013 ribbon

Well that doesn’t break anything in SharePoint. :) It also doesn’t do much for me either. So let’s add a negative left margin:

.ms-cui-TabRowRight {
     float: left;
     margin-left: -10px;

Annnnd we are back to breaking SharePoint.

Issues created after modifications

Note that if you leave the DIV as a right float (OOTB treatment) or just specify a negative left margin (which doesn’t change anything in the design) SharePoint remains happy. You can even set negative top or bottom margins. The inline style and CSS class gets changed when you try to move these items into what SharePoint perceives as the ribbon tabs space… or something like that? An absolute position OR the combination of a left float AND negative left margin creates the issue.

No big deal, I can fix troublesome CSS with new CSS (note I switched back to absolute positioning in order to better control placement):

/* Move Ribbon Tab Row Right (Share/Follow) to the left of Suite Bar Right */
.ms-cui-TabRowRight {
     position: absolute; /* Remove from content flow and create precise placement based on parent container */
     top: -35px; /* Shift above default placement */
     left: 10px; /* Add space to left between page edge and text */
     display: block !important; /* Override inline OOTB SharePoint style */

/* ms-cui-tts-scale-2 class is auto applied when .ms-cui-TabRowRight is absolute positioned -which results in small ribbon text space. Following declarations correct the issue. */
.ms-cui-tts-scale-2 .ms-cui-tt-a {
     width: auto; /* Reset small width to auto size based on length of text */
     padding: 0 9px; /* Pad out the ribbon text */

Some of this could have been avoided if I was dealing with a custom master page and just manually moved the links and icons out of the ribbon’s peripheral right area, but the idea was I needed to make a change with only CSS, so there you go. :)

How to use Icon Fonts with SharePoint

One of the current trends in the web world is to use icon fonts with and for various things in your web user interface. They are fast to load, easy to scale in size, quick to change color, and it’s simple to add effects. Icon fonts can be used in SharePoint with just a little CSS. This post contains demos for both SharePoint 2010 and 2013. Continue reading

SharePoint CSSLink

Understanding SharePoint:CSSLink and how to add your custom CSS in SharePoint 2010

CSS is a wonderful tool for branding SharePoint; unfortunately SharePoint 2010 has done a decent job of making things pretty hairy and confusing with working with CSS in a SharePoint site. Something we get asked all the time in our classes is “where do I link to my custom CSS file?” Great question and the answer isn’t just “from your master page”. Continue reading

SharePoint CSS and CSS Specificity

CSS specificity (weight) and SharePoint

When dealing with SharePoint CSS one of your biggest friends is specificity. It also happens to be one of the harder things to wrap your head around, especially if you are just getting into creating and editing CSS. Specificity is a key thing to understand for SharePoint branding and something that I cover in all my branding classes. Continue reading

What makes good SharePoint CSS?

I recently read an interesting post that I think is a good starting list for judging CSS files. You can check it out here: Judging CSS / Spotting Bad Code

Reading that article and my ensuing comment that I posted based on my experience with SharePoint led me to think… why not write this up for SharePoint?  So here I am.   :)  Let’s get started with chatting briefly about why you should even care about what makes good SharePoint CSS code. Continue reading

Ribbon visibility using CSS

This is the fourth post in a SharePoint 2010 ribbon series.  Be sure to check out posts 1through 3 as well:
1) Boil it down to the basics… the SharePoint 2010 ribbon
2) Gathering requirements for your ribbon needs
3) The Docked Ribbon

The ribbon doesn’t have to be big and scary.  SharePoint ribbon customization can be completed with just a little CSS and tweaks to your master page. In this post we are going to focus hiding the ribbon when it is not in use. Continue reading