加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

flex4 css的多种用法

发布时间:2020-12-15 05:11:51 所属栏目:百科 来源:网络整理
导读:原文地址:?http://www.voidcn.com/article/p-hdbomhdg-eo.html 下面给出一段示例代码: ? ?xml version="1.0" encoding="utf-8"? s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"? ? xmlns:s="library://ns.adobe.com/flex/spark"? ? xmlns:mx="li

原文地址:?http://www.voidcn.com/article/p-hdbomhdg-eo.html


下面给出一段示例代码:
?
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"?
? xmlns:s="library://ns.adobe.com/flex/spark"?
? xmlns:mx="library://ns.adobe.com/flex/mx" >
? <s:layout>
? ? <s:VerticalLayout horizontalAlign="center" paddingTop="20"/>
? </s:layout>
? <fx:Style>
? ? @namespace mx "library://ns.adobe.com/flex/mx";
? ? @namespace s "library://ns.adobe.com/flex/spark";
? ??
? ? global {
? ? ? font-family:Times New Roman,Times,serif;
? ? ? color:purple;
? ? }
? ? s|Label
? ? {
? ? ? font-size:18;
? ? ? font-style:italic;
? ? }
//descendant selector,要完全符合这样的层次才能有效,见结果
? ? s|HGroup s|Button s|Label
? ? {
? ? ? font-style:normal;
? ? ? font-weight:bold;
? ? }
//name selector
? ? .redFont?
? ? {
? ? ? color:#ff0000;
? ? }
? </fx:Style>
? <s:VGroup>
? ? <s:Label text="Hello World" styleName="redFont"/>
? ? <s:Button label="Click me"/>?
? </s:VGroup>
? <s:HGroup>
? ? <s:Label text="Hello World"/>
? ? <s:Button label="Click me"/>?
? </s:HGroup> ? ? ?
</s:Application>
运行结果为:

========================================== ? ?

? ? 如果将style保存为css文件:

//ExternalStyles.css
@namespace s "library://ns.adobe.com/flex/spark";
@namespace mx "library://ns.adobe.com/flex/mx";
global {
? font-family:Times New Roman,serif;
? color:purple;
}
s|Label
{
? font-size:18;
? font-style:italic;
s|Button s|Label
? font-style:normal;
? font-weight:bold;
.redFont?
? color:#ff0000;
再修改mxml文件为:
//ExternalStyles.mxml
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" >
? <s:layout>
? ? <s:VerticalLayout horizontalAlign="center" paddingTop="20"/>
? </s:layout>
? <fx:Style source="ExternalStyles.css"/>
? <s:VGroup>
? ? <s:Label text="Hello World" styleName="redFont"/>
? ? <s:Button label="Click me"/>?
? </s:VGroup>
? <s:HGroup>
? ? <s:Label text="Hello World"/>
? ? <s:Button label="Click me"/>?
? </s:HGroup> ? ? ?
</s:Application>
?
则运行结果一样

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读