【问题标题】:How to set font face for internet explorer in WordPress?如何在 WordPress 中为 Internet Explorer 设置字体?
【发布时间】:2016-04-27 07:35:15
【问题描述】:

我只在 WordPress 中为 Internet Explorer 设置字体

所有字体都位于子主题的根目录中。

这是ie-only.css中的代码

    @media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) { 

    @font-face {
    font-family: 'open_sansregular';
    src: url('opensans-regular-webfont.eot');
    src: url('opensans-regular-webfont.eot?#iefix') format('embedded-opentype'),
         url('opensans-regular-webfont.woff2') format('woff2'),
         url('opensans-regular-webfont.woff') format('woff'),
         url('opensans-regular-webfont.ttf') format('truetype'),
         url('opensans-regular-webfont.svg#open_sansregular') format('svg');
    font-weight: normal;
    font-style: normal;

    }


    .text-highlight { border: 1px solid red; font-family:open_sansregular;  }

}

您知道在子主题的根目录中找到字体系列的正确地址是什么吗?

感谢任何帮助。谢谢

【问题讨论】:

  • 你的字体 opensans-regular-webfont.eot 在哪里安装?哪个目录?
  • 嗨 Shoeb,opensans-regular-webfont.eot 在子主题内
  • 需要检查它的来源然后只有我可以评论..

标签: php css wordpress internet-explorer fonts


【解决方案1】:

我认为你没有正确设置字体路径试试这个代码。

@font-face {
font-family: 'open_sansregular';
src: url('<?php echo get_stylesheet_directory_uri(); ?>/fonts/opensans-regular-webfont.eot');
src: url('<?php echo get_stylesheet_directory_uri(); ?>/fonts/opensans-regular-webfont.eot?#iefix') format('embedded-opentype'),
     url('<?php echo get_stylesheet_directory_uri(); ?>/fonts/opensans-regular-webfont.woff2') format('woff2'),
     url('<?php echo get_stylesheet_directory_uri(); ?>/fonts/opensans-regular-webfont.woff') format('woff'),
     url('<?php echo get_stylesheet_directory_uri(); ?>/fonts/opensans-regular-webfont.ttf') format('truetype'),
     url('<?php echo get_stylesheet_directory_uri(); ?>/fonts/opensans-regular-webfont.svg#open_sansregular') format('svg');
font-weight: normal;
font-style: normal;

}

【讨论】:

    【解决方案2】:

    我能够解决我的问题。

    要在 Internet Explorer 中启用字体,请为 IE 创建一个单独的 css。 示例:

    <link rel="stylesheet" type="text/css" href="<?php echo get_stylesheet_directory_uri(); ?>/ie-only.css" />
    

    get_stylesheet_directory_uri()会得到子主题的目录

    现在在 ie-only.css

        @font-face {
        font-family: 'open_sansregular';
        src: url('fonts/opensans-regular-webfont.eot');
        src: url('fonts/opensans-regular-webfont.eot?#iefix') format('embedded-opentype'),
             url('fonts/opensans-regular-webfont.woff2') format('woff2'),
             url('fonts/opensans-regular-webfont.woff') format('woff'),
             url('fonts/opensans-regular-webfont.ttf') format('truetype'),
             url('fonts/opensans-regular-webfont.svg#open_sansregular') format('svg');
        font-weight: normal;
        font-style: normal;
    
        }
    

    上面声明的所有字体文件都应该在您正在使用的目录中可用。

    谢谢。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-08-27
      • 2011-05-03
      • 2012-02-24
      • 2012-09-08
      • 2020-05-17
      • 1970-01-01
      • 1970-01-01
      • 2012-09-12
      相关资源
      最近更新 更多