A summary of the application of CSS selector in flex4.5 _flex

Source: Internet
Author: User
CSS selectors can include, tag Selector, category selector, ID selector, intersection selector, and set selector, descendant selector, global selector, pseudo class, etc., these style applications have been supported in Flex

1. Tag Selector
The tag Selector is set based on the type of component in the Mxml file, as shown in the following example:
Copy Code code as follows:

<fx:Style>
@namespace S "Library://ns.adobe.com/flex/spark";
@namespace mx "LIBRARY://NS.ADOBE.COM/FLEX/MX";
s| textinput{
Color: #FF0000;
}
s| button{
Color: #FFFF00;
}
</fx:Style>
<s:textinput text= "text input"/>
<s:button label= "button"/>

The color of the two controls above will change.
2. Category Selector
The category selector begins with a point, followed by a category selector represented by the name of the style set by StyleName in the component, as shown in the following example:
Copy Code code as follows:

<fx:Style>
@namespace S "Library://ns.adobe.com/flex/spark";
@namespace mx "LIBRARY://NS.ADOBE.COM/FLEX/MX";
. btn2{
Color: #FF0000;
}
</fx:Style>
<s:button label= "Button2" stylename= "btn2"/>

3.ID Selector
The ID selector is a category selector that begins with a # followed by the ID name set in the component, as shown in the following example:
Copy Code code as follows:

<fx:Style>
@namespace S "Library://ns.adobe.com/flex/spark";
@namespace mx "LIBRARY://NS.ADOBE.COM/FLEX/MX";
#btn1 {
Color: #FF0000;
}
. btn2{
Color: #FF00FF;
}
</fx:Style>
<s:button id= "btn1" label= "Button1"/>
<s:button label= "Button2" stylename= "btn2"/>

4. Intersection Selector
The intersection selector is composed of two selectors directly connected, and the result is to select the intersection of their respective element ranges, as shown in the following example:
Copy Code code as follows:

<fx:Style>
@namespace S "Library://ns.adobe.com/flex/spark";
@namespace mx "LIBRARY://NS.ADOBE.COM/FLEX/MX";
s| button#btn1{
Color: #FF0000;
}
s| button.btn2{
Color: #FF00FF;
}
</fx:Style>
<s:button id= "btn1" label= "Button1"/>
<s:button label= "Button2" stylename= "btn2"/>
<s:button label= "Button3"/>

5. and set Selector
The set selector is a comma-connected selector, and the set selector selects the range of the base selector, and any form of selector is available, as the following example:
Copy Code code as follows:

<fx:Style>
@namespace S "Library://ns.adobe.com/flex/spark";
@namespace mx "LIBRARY://NS.ADOBE.COM/FLEX/MX";
s| button#btn1,s| button.btn2{
Color: #FF0000;
}
</fx:Style>
<s:button id= "btn1" label= "Button1"/>
<s:button label= "Button2" stylename= "btn2"/>
<s:button label= "Button3"/>

6. Descendant Selector
The descendant selector is also called the derivation selector, which can be used to define a style for the child elements in an element using the descendant selector, as shown in the following example:
Copy Code code as follows:

<fx:Style>
@namespace S "Library://ns.adobe.com/flex/spark";
@namespace mx "LIBRARY://NS.ADOBE.COM/FLEX/MX";
s| Hgroup s| textinput{
Color: #FF0000;
}
</fx:Style>
<s:hgroup verticalalign= "Middle" >
<s:label text= "text Input 1"/>
<s:textinput text= "Sample"/>
</s:HGroup>
<s:textinput text= "Sample"/>

7. Global Selector
Global Selector Global can apply styles to all components, as shown in the following example:
Copy Code code as follows:

<fx:Style>
@namespace S "Library://ns.adobe.com/flex/spark";
@namespace mx "LIBRARY://NS.ADOBE.COM/FLEX/MX";
global{
Color: #FF0000;
}
</fx:Style>
<s:label text= "Label"/>
<s:textinput text= "text input"/>
<s:button label= "button"/>

8. Pseudo class
A pseudo class is used to set the style of a component in a different state, as shown in the following example:
Copy Code code as follows:

<fx:Style>
@namespace S "Library://ns.adobe.com/flex/spark";
@namespace mx "LIBRARY://NS.ADOBE.COM/FLEX/MX";
s| button:up{
Color: #FF0000;
}
s| button:down{
Color: #FF00FF;
}
s| button:over{
Color: #0000FF;
}
</fx:Style>
<s:button label= "button"/>
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.