Automatically add CSS vendor prefixes
CSSfix class an automatically apply vendor prefixes to specified CSS rules.
Contents
Download
Example codes
//declaring class instance
include("./CSSfix.php");
$css = new CSSfix();
$css->from_file("./style.css");
echo $css->generate(false);
Examples in action
Example scripts provided with package in action:
Method list
- Set prefixes
- Get prefixes
- Get properties
- Ignore properties
- Add CSS from file
- Add CSS from string
- Get modified CSS
- Save modified CSS to file
Set prefixes
| Method name | set_prefixes($prefixes) |
| Description | provide array of prefixes, that should be applied, by default there are five prefixes applied to certain css properties |
| Input parameters | array $prefixes - array with supported vendor prefixes (default: array("moz", "webkit", "o", "ms", "khtml")) |
| Example input | set_prefixes(array("moz", "webkit", "o")) |
Get prefixes
| Method name | get_prefixes() |
| Description | Get array of defined prefixes |
Get properties
| Method name | get_properties() |
| Description | Get array of properties, that can be changed |
Ignore properties
| Method name | set_ignore($properties) |
| Description | Provide array of css properties, that should be ignored and vendor prefixes won't be applied |
| Input parameters | array $properties - array with css properties to ignore |
| Example input | set_prefixes(array("border-radius", "opacity", "@keyframes")) |
Add CSS from file
| Method name | from_file($css_file) |
| Description | Read css rules from file. After it will be possible to apply vendor prefixes to these CSS rules |
| Input parameters | string $css_file - path to css file |
| Example input | from_file("./styles/style.css") |
Add CSS from string
| Method name | from_string($css_rules) |
| Description | Add css rules from string. After it will be possible to apply vendor prefixes to these CSS rules |
| Input parameters | string $css_rules - string with css rules |
| Example input | from_string("div{border-radius: 10px;opacity: 0.5;}") |
Get modified CSS
| Method name | generate($min = true) |
| Description | Generate new CSS rules with applied vendor prefixes |
| Input parameters | bool $min - should css be minimized |
| Example input | generate(false) |
Save modified CSS to file
| Method name | to_file($file, $min = true) |
| Description | Generate new CSS rules with applied vendor prefixes and save it to file |
| Input parameters | string $file - path to file, which should be created bool $min - should css be minimized |
| Example input | to_file("./styles/mod_styles.css", false) |
Awards
CSS Fix class was nominated to Innovation Award please support it by voting :)
Latest changes
None for now
Support
PHP classes support forum or comments below
You may also be interested in:
Powered by BlogAlike.com










