PHP Classes

File: Example.txt

Recommend this page to a friend!
  Classes of Chris Sprucefield  >  PHP CSS Variables and Math  >  Example.txt  >  Download  
File: Example.txt
Role: Documentation
Content type: text/plain
Description: Examples
Class: PHP CSS Variables and Math
Replace variables and math expressions in CSS
Author: By
Last change:
Date: 6 years ago
Size: 715 bytes
 

Contents

Class file image Download
Assume you have the following: 

$conf['base_width'] = 10 ; 

CSS::setConf($conf) ; 
$css = CSS::load("myfile") ; // Assumes .css, you provide full path. 



myfile.css
----------------------------
.classname1 {width: [base_width]px ; }
.classname2 {width: [base_width * 2]px }


would be translated to: 

.classname1 {width: 10px ; }
.classname2 {width: 20px }


If you do fractional maths, and want the result to be integer, you can prepend the variable name by ~, performing a floor, such as: 

.classname1 {width: [base_width]px ; }
.classname2 {width: [~base_width * 1.55 + 2]px } (10*1.55 + 2 = 17.5)

translating into:

.classname1 {width: 10px ; }
.classname2 {width: 17px }

For more information send a message to info at phpclasses dot org.