CSS 当我使用 cakephp 时,我在哪里放置 PIE.htc 文件(用于使 IE 与 CSS3 一起工作)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7005442/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
where do I put the PIE.htc file (for making IE work with CSS3) when I'm using cakephp
提问by julia
I'm trying to use PIE.htc, which is a script which hopefully will allow me to use CSS3 features in IE6-8. I'm also using Cakephp (which I'm growing to love)
我正在尝试使用PIE.htc,这是一个脚本,希望可以让我在 IE6-8 中使用 CSS3 功能。我也在使用 Cakephp(我越来越喜欢它)
According to the instructions I just stick the PIE.htc file anywhere I want to and then add behavior: url(path/to/PIE.htc);
to the CSS. So I have:
根据说明,我只是将 PIE.htc 文件粘贴到任何我想要的位置,然后添加behavior: url(path/to/PIE.htc);
到 CSS 中。所以我有:
input[type=text]{
width:348px;
height:30px;
border:1px solid #ddd;
padding:3px;
background:url(../img/formfieldbg.gif) repeat-x;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
border-radius: 5px;
vertical-align:top;
behavior: url(path/to/PIE.htc);}
It also says: Note: this path is relative to the HTML file being viewed, not the CSS file it is called from.
它还说: 注意:此路径相对于正在查看的 HTML 文件,而不是调用它的 CSS 文件。
I'm using Cakephp and no matter what I put for the path and no matter where I place the PIE.htc file I can't make it work! When I view it in IE6 my inputs still don't have the lovely rounded corners like they do in FF.
我正在使用 Cakephp,无论我为路径放置什么,也无论我将 PIE.htc 文件放在哪里,我都无法让它工作!当我在 IE6 中查看它时,我的输入仍然没有像在 FF 中那样可爱的圆角。
回答by Wesley Murch
Try using an absolute path:
尝试使用绝对路径:
behavior: url(/path/to/PIE.htc);
Note the leading forward slash. This way, no matter what the current page is, the path to the .htc
file will remain the same.
请注意前导正斜杠。这样,无论当前页面是什么,.htc
文件的路径都将保持不变。
A full URL will work too:
完整的 URL 也可以使用:
behavior: url(//example.com/path/to/PIE.htc);
If you do use a full url, use a protocol relative urlso you don't get insecure content warnings when switching to https.
如果您确实使用完整 url,请使用协议相关 url,这样在切换到 https 时就不会收到不安全的内容警告。
A lot of elements need position:relative
or zoom:1
when using PIE in order to behave in IE, make sure you check the known issuespage and play around until you get it to work.
许多元素需要position:relative
或zoom:1
在使用 PIE 以在 IE 中运行时,请确保您检查已知问题页面并尝试使用,直到您使用它为止。
回答by r8n5n
I was using CodeIgniter with a mod_rewrite. Based on Septagram's answer I got the following to work
我使用带有mod_rewrite 的CodeIgniter 。根据 Septagram 的回答,我得到了以下工作
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
#if the url contains PIE.php redirect to the folder containing PIE.php
RewriteCond %{REQUEST_URI} PIE.php$
RewriteRule ^.*$ css3pie/PIE.php [NC,L]
#else just redirect to index
RewriteRule ^.*$ index.php [NC,L]
Hope this helps someone
希望这有助于某人
回答by defau1t
You need to specify the pie.php file. Its content is like below:
您需要指定 pie.php 文件。其内容如下:
<?php
/*
This file is a wrapper, for use in PHP environments, which serves PIE.htc using the
correct content-type, so that IE will recognize it as a behavior. Simply specify the
behavior property to fetch this .php file instead of the .htc directly:
.myElement {
[ ...css3 properties... ]
behavior: url(PIE.php);
}
This is only necessary when the web server is not configured to serve .htc files with
the text/x-component content-type, and cannot easily be configured to do so (as is the
case with some shared hosting providers).
*/
header( 'Content-type: text/x-component' );
include( 'PIE.htc' );
?>
That should solve the issue.
那应该可以解决问题。
回答by Septagram
If you happen to be using mod_rewrite
, than the following little hack might be for you:
如果您碰巧正在使用mod_rewrite
,那么以下小技巧可能适合您:
RewriteRule /PIE.htc$ PIE.htc [L]
Add this to .htaccess
and voila! Now PIE.htc
is magically present in every folder :)
将此添加到.htaccess
并瞧!现在PIE.htc
神奇地出现在每个文件夹中:)