|
转载自 http://blog.chinaunix.net/uid-122937-id-2880824.html
与HTML相似,Flex允许在MXML标签中通过CSS样式来设置组件的外观。到flex4.5后已经基本上支持了HTML中的所有CSS的应用方式,这里主要来列举下flex4.5中CSS选择器的使用方法。
CSS选择器可以包括,标签选择器、类别选择器、ID选择器、交集选择器、并集选择器、后代选择器、全局选择器、伪类等,这些样式应用都已经在flex得到支持。
1.标签选择器
标签选择器是根据MXML文件中组件的类型来设置的,示例如下:
<div style="margin-top: 0px; margin-right: 0px; margin-bottom: 1.1em; margin-left: 0px; width: 659px; background-color: #f5f7f8; font-family: Consolas, monospace; line-height: 1.5; padding: 0px; border: 1px solid #dddddd;" class="codeText">
- <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"/>
|
|