Skip to content

Instantly share code, notes, and snippets.

@nanjizal
Last active November 25, 2016 00:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nanjizal/8aa6e765af932ebed3a6a9eade445b6f to your computer and use it in GitHub Desktop.
Save nanjizal/8aa6e765af932ebed3a6a9eade445b6f to your computer and use it in GitHub Desktop.
CSS3 flexbox
# mac specific, last two line will need adjusting for pc and linux
-js test.js
-cp src
-main Main
-D js-flatten
-dce full
--next
-cmd echo '<!DOCTYPE html><meta charset="UTF-8"><html><head/><body><script src="test.js"></script></body></html>' >index.html
-cmd open index.html
package;
import js.Browser;
import js.html.StyleElement;
import js.html.DivElement;
import js.html.BodyElement;
import js.html.CSSStyleDeclaration;
class Main{
public static function main(){
var body: BodyElement = cast Browser.document.body;
var doc = js.Browser.window.document;
var divSection = doc.createDivElement();
var sectionStyle = divSection.style;
sectionStyle.display='flex';
sectionStyle.maxWidth = '740px';
sectionStyle.margin = '0 auto';
var texts = ['first','second','third'];
body.appendChild( divSection );
var div:DivElement;
var divStyle: CSSStyleDeclaration;
for( i in 0...3 ){
div = doc.createDivElement();
divStyle = div.style;
divStyle.margin = '10px';
divStyle.flexGrow = '1';
divStyle.flexShrink = '1';
div.innerHTML = texts[ i ];
divSection.appendChild( div );
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment