FLEX實踐:引用外部CSS檔案控制外觀

來源:互聯網
上載者:User

 

結語:如果不精通CSS或是對所經用到的控制項的屬性內容不熟悉的,我推薦一個方法:

         在頁面上設定好你想要的控制項的樣式(將顏色,大小,字型等等屬性從原始碼中COPY出來,粘貼到CSS檔案中)

 

例如:如下的button樣式是你想要的

 

在SOURCE中得到它的屬性設定

<mx:Button x="217" y="206" label="Button" width="104" height="32" fontSize="15" cornerRadius="13" color="#B62F19" fontWeight="bold" alpha="0.49"/>

 

OK,現在可以將這些屬性COPY到CSS檔案中了

CssTest.css 中添加代碼

.MyTextStyle1
        {
            font-family: Copacetix;
            font-size: 15pt;
            fontWeight:bold;
            color:#B62F19;  
            cornerRadius:13;
            width:104;
            height:32;
            alpha:0.49;
        }

 

CssTest.mxml 中代碼變為:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
    <mx:Style source="CssTest.css" />
    <mx:Text styleName="MyTextStyle" text="Embedded fonts rock!" width="305" x="431.5" y="127"/>
    <mx:Button x="512" y="253" label="Button"  styleName="MyTextStyle" />
    <mx:Button x="217" y="206" label="Button" styleName="MyTextStyle1"/>
   
</mx:Application>

 

運行結果:

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.