23 May 2011
Beginning
In this exercise you will use advanced CSS selectors to style the sample application as shown in Figure 1.
In this exercise, you will learn how to:
In this section you will use a descendant selector to change the Button controls.
MonthlyEvents component, create a descendant selector for Button control instances that are located within the Panel containers.cx|MonthlyEvents
{
color: #0B85B7;
}
s|Panel s|Button
{
}
color property to #000000 (black) and the chromeColor property value to #64BC48 (green).s|Panel s|Button
{
color: #000000;
chromeColor: #64BC48;
}
You should see the buttons located within the panels have a green background and black text, whereas the Logout button is unchanged (see Figure 2). The descendant selector only affected Button controls that are in Panel containers.
The Scroller control is also a descendant of the Panel container and uses Spark Button controls in its skin for the track, thumb, up, and down buttons. As a result, any color property applied to a Spark Button control within a Panel container will also be applied to the Scroller control (see Figure 2).
Button controls within Panel containers, create a descendant selector for the Button controls used within Scroller controls within Panel containers.s|Panel s|Button
{
color: #000000;
chromeColor: #64BC48;
}
s|Panel s|Scroller s|Button
{
}
chromeColor property value to #555555 (dark gray).s|Panel s|Scroller s|Button
{
chromeColor: #555555;
}
The scrollbars within the panels are now dark gray (see Figure 3).
s|Panel s|Button:down
{
color: #000000;
chromeColor: #64BC48;
}
You should see that the buttons within the panels have a green down state whereas the Logout button does not (see Figure 4).
Panel container descendant selector, add a selector for the up state of the Button control and assign the color property value to #FFFFFF (white) and the chromeColor property value to #555555 (dark gray).s|Panel s|Button:down
{
color: #000000;
chromeColor: #64BC48;
}
s|Button:up
{
color: #FFFFFF;
chromeColor: #555555;
}
up state, add a descendant selector for the over state for the Button controls within the Panel containers and assign the color property a value of #000000 (black) and the chromeColor property value to #0D86B8 (blue).s|Button:up
{
color: #FFFFFF;
chromeColor: #555555;
}
s|Panel s|Button:over
{
color: #000000;
chromeColor: #0D86B8;
}
You should see all the buttons in the application are a dark gray color and turn blue when the mouse is over them (see Figure 5).
Note that the scroll bar is also affected by these changes.
Button control used within the Scroller control within the Panel container.over state of the Button control.s|Panel s|Scroller s|Button:over
{
chromeColor: #555555;
}
Button controls in the Scroller control within the Panel container and apply it to the down state of the Button control.chromeColor property to the descendant selector and give it a value of #555555.s|Panel s|Scroller s|Button:over
{
chromeColor: #555555;
}
s|Panel s|Scroller s|Button:down
{
chromeColor: #555555;
}
You should see that when you mouse over or click the scroll bar, the color is now gray (see Figure 6).
In this section, you will use a CSS id selector to change the color of the employee name within the EmployeeOfTheMonth component.
id property with a value of employeeName.<s:Label id="employeeName"
text="ATHENA PARKER"
fontWeight="bold"/>
id property value, employeeName.#employeeName
{
}
color property and assign a value of #FF0000.#employeeName
{
color: #FF0000;
}
The employee name within the Employee of the Month panel is now red (see Figure 7).
In this exercise you used advanced CSS selectors to style the sample application.
This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License. Permissions beyond the scope of this license, pertaining to the examples of code included within this work are available at Adobe.