Skip to main content
Technology

Flex Text Alignment & Layout

I know it’s super simple, but I’ve been banging my head on text layout for a couple of hours. I wanted 2 text boxes to have less space between them (leading) than the default. After trying many approaches, I finally figured out that I can set a negative paddingBottom to achieve the desired effect.

Flex Code:

<mx:VBox>
	<mx:Text text="Line 1" styleName="line1Style"/>
	<mx:Text text="Line 2" styleName="line2Style"/>
</mx:VBox>

CSS:

.line1Style {
	fontSize: 38;
	fontWeight: bold;
	paddingBottom:-10;
}

.line2Style {
	fontSize: 16;
}

While investigating this effect, I also found some other interesting layout resources:
Adobe’s Quickstart guide to positioning
Kevin Hoyt’s review of positioning in Flex

Contributors

Peter

Peter

I lead a fantastic team of WordPress developers building enterprise level WordPress systems. On occasion I have been known to speak at conferences on the topics of Freelancing, WordPress, and the meaning of life, though I tend to spend much of my performance energy on my music. Perhaps one day I will figure out how to merge the two without having to write songs about debugging Javascript.