开发者

Flex, HBox: how to horizontally center all children?

I cannot center the components in my VBox. I would like to set the standard css element "align: center". How can I do that in Flex ?

<mx:VBox>
    <mx:LinkButton label="Tag1" />开发者_如何转开发
    <mx:Image source="@Embed(source='../icons/userIcon.png')" />
    <mx:Label id="username" text="Nickname" visible="false" fontWeight="bold"   />
</mx:VBox>

thanks


Simply put, you can do this:

<mx:VBox width="200" horizontalAlign="center">
    <mx:Label text="foo" />
</mx:VBox>

I just tried this example, and it worked fine. If the container's width is being dictated by its children, it might not appear to align correctly:

<mx:VBox horizontalAlign="center" borderStyle="solid">
    <mx:Label text="foo" />
    <mx:Label text="bar" />
</mx:VBox>

However, further specifying the width shows this attribute to work:

<mx:VBox width="200" horizontalAlign="center" borderStyle="solid">
    <mx:Label text="foo" />
    <mx:Label text="bar" />
</mx:VBox>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜