CSS中的条件CSS不工作 [英] Conditional CSS in CSS not working

查看:83
本文介绍了CSS中的条件CSS不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我有这个css代码:

  .onetoone {
position:relative;
margin:10px auto 5px;
padding:20px;
width:878px;
[if! IE] height:1241px;
[if IE] height:241px;
border:1px solid #AAAAAA;
behavior:url(PIE.htc);
}

但是我在IE和Firefox上没有看到任何不同的高度.onetoone ,两者仍然具有相同的214px高度。



我错过了什么?


解决方案

您已阅读使用文件吗?



根据网站,您必须编写css,并使用其在线工具然后你已经包括 c-css.php 以使其工作。

  @import/media/css/c-css.php; 

根据网站,这应该可以解决问题。

  .onetoone {
位置:相对;
margin:10px auto 5px;
padding:20px;
width:878px;
border:1px solid #AAAAAA;
behavior:url(PIE.htc);
}
[if!IE] .onetoone {
height:1241px;
}

[if IE] .onetoone {
height:241px;
}

编译后会变成一个像这样的大文件这里,您像上面所说的那样包括。






但是,我会用好的老式方式。

 <! -  [if IE]> 
< style>
.onetoone {
height:241px;
}
< / style>
<![endif] - >

<! - [if!IE]>
< style>
.onetoone {
height:1241px;
}
< / style>
<![endif] - >

应该工作。






更新



在加载所有主css文件之后,而不是加载不同的样式,

 <! -  [if IE]> 
< link rel =stylesheettype =text / csshref =fixforie.css/>
<![endif] - >
<! - [if IE 6]>
< link rel =stylesheettype =text / csshref =fixforie6.css/>
<![endif] - >


so I have this css code:

.onetoone{
    position: relative;
    margin: 10px auto 5px;
    padding: 20px;
    width: 878px;
    [if ! IE] height: 1241px;
    [if IE] height: 241px;
    border: 1px solid #AAAAAA;
    behavior: url(PIE.htc);
}

However I don't see any different height on .onetoone in IE and Firefox, both are still have the same 214px height. It should has a 1232px height in firefox and 241px height in IE 8, right?

What did I miss?

Thanks for all your answers.

解决方案

Have you read the usage file?

According the website, you have to write the css and compile it using its online tool and then you have include c-css.php to get it working.

@import "/media/css/c-css.php";

According to example from this website, this should fix the problem.

.onetoone{
    position: relative;
    margin: 10px auto 5px;
    padding: 20px;
    width: 878px;
    border: 1px solid #AAAAAA;
    behavior: url(PIE.htc);
}
[if !IE] .onetoone {
    height: 1241px;
}

[if IE] .onetoone {
    height: 241px;
}

After you compile it becomes a huge file like this one here and you include like the way I said above.


However, I would go with the good old fashioned way I knew. And it was to include different css with the conditional CSS comments

<!--[if IE]>
   <style>
      .onetoone {
        height: 241px;
       }
   </style>
<![endif]-->

<!--[if !IE]>
   <style>
      .onetoone {
        height: 1241px;
       }
   </style>
<![endif]-->

Should work either way.


Update

Instead of loading different style like the one in my example load different file in the end after loading all the main css files in this way.

<!--[if IE]>
<link rel="stylesheet" type="text/css" href="fixforie.css" />
<![endif]-->
<!--[if IE 6]>
<link rel="stylesheet" type="text/css" href="fixforie6.css" />
<![endif]-->

这篇关于CSS中的条件CSS不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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