在WordPress中以正确的方式排队IE条件样式表

在WordPress中以正确的方式排队IE条件样式表

本文介绍了在WordPress中以正确的方式排队IE条件样式表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道这个问题之前在stackoverflow,但对于我的生活我不能得到我的条件样式表加载和工作的所有版本的IE。我很感激任何提前给予的帮助,它真的得到了我,我不知道该从这里做什么。我也试着加载IE样式表在标题,但似乎没有工作。我的主题不是儿童主题。

I know this question has been asked before on stackoverflow, but for the life of me I cannot get my conditional stylesheet to load and work for all versions of IE. I appreciate any help given in advance, it's really been getting to me, and I'm not sure what to do from here. I also tried loading the IE stylesheet in the header but that didn't seem to work either. My theme is not a child theme.

这是我的功能代码:

function theme_styles() {

global $wp_styles;

wp_enqueue_style( 'bootstrap_css', get_template_directory_uri() . '/css/bootstrap.min.css' );
wp_enqueue_style( 'glyphicons_css', get_template_directory_uri() . '/css/glyphicons.css' );
wp_enqueue_style( 'glyphiconssocial_css', get_template_directory_uri() . '/css/social.css' );
wp_enqueue_style( 'main_css', get_template_directory_uri() . '/style.css' );

    /**
 * Load our IE-only stylesheet for all versions of IE:
 * <!--[if IE]> ... <![endif]-->
 *
 * NOTE: It is also possible to just check and see if the $is_IE global in WordPress is set to true before
 * calling the wp_enqueue_style() function.  If you are trying to load a stylesheet for all browsers
 * EXCEPT for IE, then you would HAVE to check the $is_IE global since WordPress doesn't have a way to
 * properly handle non-IE conditional comments.
 */
wp_enqueue_style( 'ie_css', get_template_directory_uri() . '/ie.css', array('bootstrap_css', 'main_css')  );
$wp_styles->add_data( 'ie_css', 'conditional', 'IE' );


} add_action( 'wp_enqueue_scripts', 'theme_styles' );


推荐答案

注意,注释的样式似乎在FF Firebug中是不可见的,而在Chrome开发者工具中则是显示的。

That method works fine. Note that commented styles seem to be invisible in FF Firebug, in Chrome developer tools on the other hand they are displayed.

add_action( 'wp_enqueue_scripts', 'so27214782_wp_enqueue_scripts' );
function so27214782_wp_enqueue_scripts()
{
    global $wp_styles;

    wp_enqueue_style( 'so27214782_ie', get_template_directory_uri() . '/ie.css', array(), '27214782', 'all' );

    $wp_styles->add_data( 'so27214782_ie', 'conditional', 'IE 6' );
}

这篇关于在WordPress中以正确的方式排队IE条件样式表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-31 01:39