使用内容类型的PHP文件:text/css中断与Microsoft Edge的最新版本(13) [英] PHP file using content-type: text/css breaks with newest version (13) of Microsoft Edge

查看:28
本文介绍了使用内容类型的PHP文件:text/css中断与Microsoft Edge的最新版本(13)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从数据库中提取CSS变量,然后使用这些样式编译动态样式表.我一直使用PHP文件查询这些样式,然后将其输出为标题内容类型:text/css.

I need to pull CSS variables from a database and compile a dynamic stylesheet with those styles. I've always used a PHP file to query those styles and then output that with a header content-type: text/css.

header("Content-type: text/css; charset=utf-8");

在最新版本的Microsoft Edge 13中,这种方法似乎不再起作用.知道为什么可以代替该技术吗?

With the latest release of Microsoft Edge, version 13, this method no longer seems to be working. Any idea why or what I can use in place of this technique?

此方法的详细说明如下: http://code.tutsplus.com/articles/supercharge-your-css-with-php-under-the-hood--net-6409

The technique is explained in more detail here: http://code.tutsplus.com/articles/supercharge-your-css-with-php-under-the-hood--net-6409

样式表(PHP文件输出为CSS)在查看源代码时完全为空白,但仅在Edge版本13中.所有其他浏览器仍然可以正常工作.

The style sheet (PHP file output as CSS) is completely blank when viewing the source, but only in Edge version 13. All other browsers continue to work just fine.

推荐答案

解决方案是更改动态CSS文件的实现.在上面引用的示例中,我使用了指向CSS文件的链接:

The solution was to change the implementation of the dynamic CSS file. In the example cited above, I'm using a link to a CSS file:

<link rel="stylesheet" href="style.php">

Edge似乎正在检查文件扩展名,但由于文件扩展名不是.css,因此无法加载CSS样式.要解决此问题,我改用PHP来包含文件:

Edge seems to check the file extension and fails to load the css styles because the file extension isn't .css. To work around this, I used PHP to include the file instead:

include 'style.php';

然后在PHP文件中,只需在CSS代码周围回显样式标签即可.

Then within the PHP file, simply echo style tags around the CSS code.

<style>
     .class {
          property: none;
     }
</style>

此实现方式的根本不同之处在于,从浏览器查看页面源时,样式不再包含在单独的文件中,而是在页面的头部内嵌显示.

This implementation is fundamentally different in that the styles are no longer included in a separate file when viewing the page source from the browser, but rather are displayed inline within the head section of the page.

这是我能够获得使用PHP生成的动态样式以与Microsoft Edge一起使用的唯一方法.如果其他人找到了另一种方法,请发布替代解决方案.

This was the only way I was able to get dynamic styles generated with PHP to work with Microsoft Edge. Please post alternate solutions if anyone else has found another method.

这篇关于使用内容类型的PHP文件:text/css中断与Microsoft Edge的最新版本(13)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆