我需要一些帮助来编写一个很棒的类来获取样式表,检测浏览器特定的CSS3规则,并添加对所有兼容浏览器的支持。这样,我们就可以为一个浏览器编写样式表,然后在准备好生产时处理CSS文件。
到目前为止,我对这堂课的看法是:
class CssRewriter {
public function reformCss($file) {
// Get the CSS as a string
$cssString = file_get_contents($file);
// Use regex to capture all styles delimited by {...}
// Use regex to determine if the any of the captured styles are browser
// specific (starts with -moz, -webkit, etc)
// Determine which CSS3 rules are not present and add them to the style
// (so if you have -moz-linear-gradient, automatically add the webkit
// version)
}
}