Servoy supports the use of HTML cascading style sheets (CSS) for styling applications. These text files are stored in the resource project. A resource project can have many CSS files, and more than one CSS can used in a solution.
The styles in a CSS apply to a form and the elements on a form. Although the solution can utilize multiple style sheets, only one style sheet at a time can be used on a form.
Benefits of using CSS in Servoy include:
To create a style in Servoy:
TIP
It is normally easier to work with an existing style. Most of the sample solutions have a style associated with them and these style are imported when the solution is imported into Servoy Developer. You can also create a new style and copy/paste different entries from one style to another.
To open an existing style sheet:
A style sheet for Servoy has basic style definitions and style definition classes.
The style definitions for Servoy are as follows:
Under any of these style definitions, the developer can create many style definition classes. For example, the label style definition could have the style definition classes label.title, label.small, and label.bold.
Each definition and definition class can have one or many properties associated with it. Properties specified within the style definition are inherited(cascaded) to any style definition class under it. Study the example below
label { color: #ffffff; border-style: solid; font: bold 10pt Verdana; } label.mytext { color: red; vertical-align: middle; border-width: 1px 1px 1px 1px; border-color: #111111 #111111 #111111 #111111; margin: 2px 2px 2px 2px; }
Notice that the border style and font are not modified in the mytext class. This means if a label were specified to use mytext for its style, it would be bold, 10pt, Verdana because that is what is specified in the parent style definition. The color would be red (not black) because that was overridden by the mytext definition class.
In order to use a style sheet, the style sheet must be applied to a form. Solutions do not have a style sheet applied, only forms. Styles for the elements on a form are dependent on the style sheet applied to the form.
A style can be applied to a form in one of two ways.