Creating SharePoint 2010/2013 themed buttons

In my new job we are making use of the SharePoint 2013 themes.  This will allow us to quickly identify which SharePoint portal we are using at a glance.  I wanted to create a customized CSS button which would match the SharePoint theme.

To do this, I needed to apply two styles to the same link; my own to create the button, and the Microsoft SharePoint style for color.

First, my style:

<style type="text/css">

.btn_1line_xSma{
  padding:2px 2px 2px 2px;
height:15px;
margin:1px 5px 5px 5px;
display: inline-block; 
width:300px;
font-family:Arial,sans-serif;
text-align:center;
text-transform:uppercase;
float:none;
color: white !important;
font-weight:normal;
font-size:13px;
vertical-align:middle;
text-decoration:none !important;
opacity:1.0; 
filter:alpha(opacity=100);

}
.btn_1line_xSma:hover{
color:#DCDCDC !important;
opacity:0.85; 
filter:alpha(opacity=85);
}

This creates a button that I find visually appealing.  The next step was to find the right Sharepoint style in core15.css to get the correct color.  Eventually I found it: ms-ContentAccent1-bgColor.  There are 6 accent colors so you can have some fun with them.

The last step is to add the link on the page.  This is the HTML that you add to your page.

<a href="#" class="ms-ContentAccent1-bgColor btn_1line_xSma">button</a>

And that's all it takes.  I like the simplicity of putting just an HTML link on the page and having output of a button with a dynamically changing color, and that even reacts to the mouseover.





Comments

Popular posts from this blog

Setting SharePoint announcements to auto delete after expiration

Updating a single field in a SharePoint List using Power Automate Flows

SharePoint driven rich text dashboard using jqueryui. (JQuery file)