Variables in math

37 views
Skip to first unread message

timk...@gmail.com

unread,
Jan 11, 2010, 12:25:33 PM1/11/10
to xCSS - OO CSS framework
I expected this to work, but it did not:
vars {
$column_width = 60px;
$gutter = 20px;
$input_padding = 10px;
$input_border = 1px;
$column = [$column_width + $gutter];
$col1 = [$column * 1 - $gutter];
$col2 = [$column * 2 - $gutter];
$col3 = [$column * 3 - $gutter];
$col4 = [$column * 4 - $gutter];
$col5 = [$column * 5 - $gutter];
$col6 = [$column * 6 - $gutter];
$col7 = [$column * 7 - $gutter];
$col8 = [$column * 8 - $gutter];
$col9 = [$column * 9 - $gutter];
$col10 = [$column * 10 - $gutter];
$col11 = [$column * 11 - $gutter];
$col12 = [$column * 12 - $gutter];
}

Are you not allowed to use math defined variables within other math
variables like this?

Anton Pawlik

unread,
Jan 11, 2010, 4:05:44 PM1/11/10
to xc...@googlegroups.com
Thanks for pointing out this bug. I didn't test how the nesting of math vars behave! I've uploaded a fix for this bug to googlecode and github (v1.0.1), please check it out and let me see how it worked out on your website. I'm really interested in this grid solution. I also would like to remind you that you can extend the unsemantic classes of other grid frameworks like yaml and 960.gs to inherit theirs style properties.
Message has been deleted

timk...@gmail.com

unread,
Jan 11, 2010, 4:39:25 PM1/11/10
to xCSS - OO CSS framework
Works like a charm!

Yep, I started translating a basic grid to lessCSS, but extending
mixins weren't really powerful enough to use effectively. Hoping class
extensions with xCSS will be the ticket!

Jarda Cvrček

unread,
Jan 11, 2010, 6:33:59 PM1/11/10
to xCSS - OO CSS framework
Hi Anton, at first thanks for a great job you've done!

I'm trying to convert typographic "css framework" baseline_type into
dynamic style sheet. I've found another bug.

vars{
$base_font_size = 14px;
$line_top_span = 6px;
$line_height = 20px;
$list_margin_left = 20px;

$h_size = [$line_height * 2]; // gives 40px OK
$h_top_span = [$line_height / 2]; // gives 10px OK
}

but when I set $line_height by sum of two previously set variables it
fails

vars{
$base_font_size = 14px;
$line_top_span = 6px;
$line_height = $base_font_size + $line_top_span; // gives 20px OK
$list_margin_left = 20px;

$h_size = [$line_height * 2]; //gives 23px FAIL
$h_top_span = [$line_height / 2]; //gives 17px FAIL

Jarda Cvrček

unread,
Jan 11, 2010, 6:43:43 PM1/11/10
to xCSS - OO CSS framework
Sorry, I've posted the text unwillingly early :(

this works:

$h_size = [($line_height) * 2]; //gives 40px OK :)
$h_top_span = [($line_height) / 2]; //gives 10px OK :)

tested on verion 1.0.1

I think autobracketing variables in the formulas should be
worthful. ;)

Cheers

Anton Pawlik

unread,
Jan 12, 2010, 3:13:45 AM1/12/10
to xCSS - OO CSS framework
yes that would be a nice option! i need to test out what works best.
1.0.2 will provide a fix for this bug. lets hope i can get it out this
week. I'm also looking forward to see the results of your typo
framework extension!

Andrew

unread,
Sep 13, 2012, 3:54:05 PM9/13/12
to xc...@googlegroups.com
Did you ever release 1.0.2?
Reply all
Reply to author
Forward
0 new messages