Skip to main content
InSource Solutions

TN - 1271 Using Cascading Style Sheets in j5

Description

 

This article from InSource shows how to leverage Cascading Style Sheets in j5

  • Author: Ron Tanner
  • Published: 06/27/2022
  • Applies to: j5 2019

Details

Using Cascading Style Sheets in j5

Cascading Style Sheets (CSS files) can be added in different locations to affect different levels of a j5 system. The location determines where the rules will be applied in the system. 

clipboard_e82cfcceb019c02fe1c4b8e0b5c1b6e9c.png

To apply a CSS to all field labels the entire j5 site to a particular color you would add a site.css file to the project root.  The contents would be as follows: 

Label { 

color:#ff9900; 

With the use of CSS classes in the site.css file you can apply CSS more specifically. 

Specific selectors will override general selectors.  

Example: 

  • A selector at the module level will be more specific than a matching one at a site level 
  • A selector with a CSS class component (example: Label.important) will be more specific than one without (example: Label) 

Example:  adding a module.css file to the Organization module. 

clipboard_e4c44572989224ad87530fa976838d885.png

 Field 

 background-color:#00FF00

color:#ff9900

Label 

 background-color:#a0a0a0

color:#4F4F4F

The result of the logbooks in this module: 

clipboard_e6d6939af8d0ec8764688376c7a6af280.png

clipboard_e28c868ddc929d23359918c3a2bb153ef.png

 Adding a CSS file to the logbook (logbook.css) should be located at the same level as the logbook.yml file.  

 

Example: 

Adding the tag to the specific field(s):  

clipboard_e0ce39ee196ad4a921fffcf01c24c9d23.png

 Adding the logbook.css file at the same level as the logbook.yml file: 

clipboard_e68494ff902cc3b1da4acad2789a9214b.png

 The logbook.css file: 

Label.asset_type 

 background-color:#FF0000

 font-weightbold

 

Result: 

clipboard_e87ae9ce6291d4cd09cba3336b677110e.png

 

You can also add colors to field options: 

There is an option to apply colors to the field options in the logbook list view (grid view).

Example: colors can be added to a select type field and this will then be applied and displayed in the grid view. 

clipboard_eb48ad1c432ad8050889df50683f78de3.png

clipboard_e5f9ab06bb0cf6a1c226a764f7acbac39.png

  • Was this article helpful?