Cascading Style Sheets (CSS)
Using CSS, you can provide rules that specify both markup and
layout properties of widgets. These rules are linked to certain
widgets using selectors. Selectors may match widgets
based on the style class or widget id of the widget or one of
its ancestors.
The important API methods and class for working with your
application stylesheet are:
- WApplication::useStyleSheet()
- WApplication::styleSheet() returns the internal stylesheet
(an instance of WCssStyleSheet), which can be manipulated
dynamically to add, modify or removing rules.
- WWidget::setStyleClass()
- WWidget::setId()
Most of the capabilities of CSS are also exposed in the WWidget
API, and can thus be directly specified for a single
widget. Properties that are related to layout can be specified
using methods of WWidget, while properties that are decorative
can be set in methods of WCssDecorationStyle, which can be
accessed using WWidget::decorationStyle().