You can use a cascading style sheet (CSS) to change the appearance of the content you publish to Zendesk. For example, if you wanted to change the appearance of notes or warnings, you could use CSS to change the colors, sizing, spacing, etc.
As part of the publishing process, Paligo converts the Paligo content into HTML for Zendesk. The element names in the Paligo content are transformed into divs with class names, for example, the procedure element is converted into a div with class="procedure". In your CSS stylesheet, you can use CSS to style the classes.
If you are new to CSS, the important thing to understand is that a CSS file does not affect your content in Paligo. It just tells a browser how to display your published content.
Tip
If you want to learn about CSS, many websites provide tutorials and information, including www.w3schools.com. There is also an excellent example of what you can achieve with CSS at http://www.csszengarden.com.
To see the underlying code of a page, see Browser Inspection Tool.
You can create your own CSS file and use that to style your Zendesk content. When creating a CSS file, it is important that the:
-
CSS is valid
-
CSS file is added to the Assets in Zendesk
-
CSS file is referenced in the document-head.hbs template in Zendesk.
Here, we assume that you have already published to Zendesk and have added the paligo-zd.css file to your Zendesk assets and referenced it in the document-head.hbs template (as described in Customize Zendesk articles using CSS).
-
Use your web browser's inspection tool feature to identify the styles that you want to change, see Browser Inspection Tool.
-
Use a CSS editor to create a new CSS file.
-
Make your changes to the CSS.
Tip
If you want to learn about CSS, many websites provide tutorials and information, including www.w3schools.com. There is also an excellent example of what you can achieve with CSS at http://www.csszengarden.com.
-
Save the CSS.
-
Upload your CSS file to your Zendesk Assets.
To upload, select Customize Design > Edit theme > Edit Code and then add or drag and drop your CSS file into the Assets folder.
-
Change the reference in the document_head.hbs template in Zendesk.
To edit the document_head.hbs template, select Customize Design > Edit theme > Edit Code and then select the document_head.hbs template. Add the reference to your .css file at the bottom of the list of references, for example, add:
<link href=“{{asset ‘mycustomstyles.css’}}” rel=“stylesheet” type=“text/css” />
Important
The order of the references to css files is important. The web browser will apply the styles from the top reference first, then the second reference, and so on. So if there are styles in the last referenced CSS file that conflict with styles in the first CSS file, the browser will use the styles in the last CSS file. The only exception is where "!important" is used in the styles (!important will take priority, unless it conflicts with another !important, in which case, the first-to-last cascading rule applies).
-
Publish your changes in Zendesk.
Example 15. Customizing Tables with CSS
In this example, you will see how you can use your own CSS file to change the appearance of tables. We'll start with an "About Space Travel" article that contains a table.
|
|
To make the style changes, you start by using the web browser's inspection feature to look at the styles that are currently applied to the content. The parts of the code that you need to style are the overall table (table), table header (th), and table rows (tr).
You decide to create your own css file for styling the table.
Using a CSS editor, you create the following CSS:
/*Set border on table head and table cells */ table td, table th{ border: 1px solid #666; } /*Set width and border spacing for entire table */ table{ width: 98%; border-spacing: 0px; } /* alternating table row colors*/ tr:nth-child(even) {background: #f8fbfd} tr:nth-child(odd) {background: #e8f4fb} /* set rounded corners to zero initially */ th, td { border-radius: 0; } /*set amount of rounding per corner */ thead tr:first-child th:first-child, table tr:first-child td:first-child, tbody tr:first-child th:first-child { border-top-left-radius: 0.6em; } thead tr:first-child th:last-child, table tr:first-child td:last-child, tbody tr:first-child th:last-child { border-top-right-radius: 0.6em; } tbody tr:last-child td:first-child, table tr:last-child td:first-child, tbody tr:last-child th:first-child { border-bottom-left-radius: 0.6em; } tbody tr:last-child td:last-child, table tr:last-child td:last-child, tbody tr:last-child th:last-child { border-bottom-right-radius: 0.6em; } thead + tbody tr td, tr + tr td , tr + tr th { border-top: 0; } tr th + th, tr td + td { border-left: 0; } /* shade table header cells */ table th { background-color: #0072ef; color: #FFF; }
You save the CSS file as "custom-table.css".
Now you need to add the file to Zendesk and set it to be referenced for each Zendesk article. In Zendesk, you browse to Customize design > Edit theme > Edit code and add the custom.table.css as an asset.
You then open the document_head.hbs template and add the following line at the bottom of the list of references to CSS files:
<link href=“{{asset ‘custom-table.css’}}” rel=“stylesheet” type=“text/css” />
You publish the template to save the changes.
Now when you view the "About Space Travel" article, it uses the table styles from your custom CSS file (with the exception of styles that are set to !important in the other CSS files).
Comments
0 comments
Article is closed for comments.