Apply CSS on a Specific SharePoint Ribbon Bar Button?

三世轮回 提交于 2019-12-06 12:25:14

Found the solution to this solely via CSS thanks to http://online.appdev.com/edge/blogs/doug_ware/archive/2011/08/02/hiding-a-sharepoint-ribbon-button-with-css.aspx

The trick is that for any '.' within the SharePoint ID (Which do unfortuenately include . as part of their names and are non-editable) you need to preceed each with '\' to become '\.' so in your original example you'll find that:

#Ribbon\.DocLibListForm\.Edit\.Commit\.CheckIn-Large {display:none;}

Works like a charm! :-)

Jim Parker

Well, I found a solution. It doesn't use CSS, but rather javascript to hide a specific button in the ribbon bar. Here is the code to hide the Check-In button:

<script type="text/javascript">
var elem = document.getElementById("Ribbon.DocLibListForm.Edit.Commit.CheckIn-Large");
elem.style.display = "none";
</script>

To implement this, I simply created a text file containing the above code, then dropped a CEWP onto my list edit form which linked to this file, and boom--done!

Thanks @Prozaker for your CSS tips--I learned something new today (besides that I suck at CSS :-)

It would be really helpful if you could post the part of the html you need help with.

However your css isn't using the important rule properly, the !important needs to be before the ; something like this:

You also need to separate with a space any child elements you are referencing, the first example needs to be written like this:

a#Ribbon .DocLibListForm .Edit .Commit .CheckIn-Large { 
     display: none !important; 
}

It could be re written like this:

a#Ribbon .DocLibListForm .CheckIn-Large { 
     display: none !important; 
}

Given that only 1 element is named .CheckIn-Large that is a child element of .DocLibListForm

For these kind of issues you can use the IE developer bar (or firebug if you use firefox), it should come bundled with ie8+ which can help you with this sort of things, letting you edit the css in real time.

I would advise against using the !important rule because it modifies the way that CSS normally operates.

{edit}

since dots are part of your ID, you can try this:

#Ribbon.DocLibListForm.Edit.Commit.CheckIn-Large { 
     display: none !important;
}

However without actual HTML code, it is still hard to tell, maybe you can paste the part that's giving you issues on pastebin.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!