Drupal 7浏览器特定的css [英] Drupal 7 Browser specific css
问题描述
您可以在您的template.php文件中使用preprocess_html 主题挂钩和 / p> 编辑:由于chrome没有条件注释,您可以检查$ _SERVER ['HTTP_USER_AGENT']: 但在此之前,尝试修复您的css规则! How can i have a browser specific css in Drupal 7 . I would like to load chrome.css if browser is chrome . Please help You can do this in your template.php file with a preprocess_html theme hook and drupal_add_css function. You will find example in drupal 7 theme, for example in bartik : Edit : since there are no conditional comments for chrome, you can check $_SERVER['HTTP_USER_AGENT'] : But before doing this, try to fix your css rules ! 这篇关于Drupal 7浏览器特定的css的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
//为IE
添加条件样式表drupal_add_css(path_to_theme()。'/css/ie.css',array ('group'=> CSS_THEME,'browsers'=>数组('IE'=>'lte IE 7','!IE'=> FALSE),'preprocess'=> FALSE));
drupal_add_css(path_to_theme()。'/css/ie6.css',array('group'=> CSS_THEME,'browsers'=> array('IE'=>'IE 6','! IE'=> FALSE),'preprocess'=> FALSE));
if(isset($ _ SERVER ['HTTP_USER_AGENT'])
& & stripos($ _ SERVER ['HTTP_USER_AGENT'],'chrome')!== false){
drupal_add_css(...);
}
// Add conditional stylesheets for IE
drupal_add_css(path_to_theme() . '/css/ie.css', array('group' => CSS_THEME, 'browsers' => array('IE' => 'lte IE 7', '!IE' => FALSE), 'preprocess' => FALSE));
drupal_add_css(path_to_theme() . '/css/ie6.css', array('group' => CSS_THEME, 'browsers' => array('IE' => 'IE 6', '!IE' => FALSE), 'preprocess' => FALSE));
if (isset($_SERVER['HTTP_USER_AGENT'])
&& stripos($_SERVER['HTTP_USER_AGENT'], 'chrome')!==false) {
drupal_add_css( ... );
}