IE和其他的条件内联CSS? [英] Conditional In-Line CSS for IE and Others?
问题描述
我正在查看此网站的源代码。当你向下滚动时,页面会根据你当前的滚动位置而改变 - 这会产生很好的效果。
I was looking at the source code for this site. As you scroll down, the page changes based on your current scroll position - makes for a nice effect.
在FireFox中查看页面的来源,我注意到他们使用了 -webkit-transform:matrix(a,b,c,d,0,0);
来处理div的移动。但是,在IE中查看相同的源时,它仅显示为 transform:matrix(a,b,c,d,0,0);
这些样式属性是 in-line 并显示如下:
Looking at the source for the page in FireFox, I noticed they use -webkit-transform:matrix(a, b, c, d, 0, 0);
to handle the movement of the divs. However, when viewing the same source in IE, it appears only as transform: matrix(a, b, c, d, 0, 0);
These style attributes are in-line and appear as the following:
FireFox:
<div class="card gift" style="z-index: 0; -webkit-transform: matrix(a, b, c, d, 0, 0); right: 198px; top: 323px; opacity: 1;"></div>
IE:
<div class="card gift" style="z-index: 0; transform: matrix(a, b, c, d, 0, 0); right: 198px; top: 323px; opacity: 1;"></div>
在前面的所有例子中, a
, b
, c
和 d
都是基于的动态变量当前滚动位置。
In all the previous examples, a
, b
, c
and d
are all dynamic variables based on the current scroll position.
我查看了这个关于条件CSS发布SO,但他们没有提及内联样式,如上面的代码所示。
I looked at this post on SO regarding conditional CSS, but they do not mention in-line styles, as shown in the code above.
这样的事情可以吗?我试过以下,但无济于事(小提琴这里):
Is such a thing possible to do? I've tried the following, to no avail (fiddle here):
<div class="testing" style="<!--[if IE]>background-color: #321;<!--[if !IE]> -->background-color: #F00;<!-- <![endif]-->"></div>
如果无法使用内联条件CSS,那么它们是怎样的呢?根据浏览器更改内嵌样式?我最好的猜测是在页面加载后添加属性的JavaScript,作为滚动位置的函数。
If in-line conditional CSS is not possible, then how are they changing the in-line styles based on browser? My best guess is JavaScript to add the properties after the page loads, as a function of scroll position.
谢谢。
编辑:
查看提供的链接,其中包含
Looking at the link provided, they include
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
<!--[if IE 9]> <html class="no-js lt-i10 ie9"> <![endif]-->
<!--[if gt IE 9]><!--> <html class="no-js"> <!--<![endif]-->
位于页面顶部,几乎与SO链接中的答案之一相同提供。但我不确定那些代码行是做什么的。这是解决方案的一部分吗?
at the top of their page, which is almost identical to one of the answers in the SO link I provided. But I'm not really sure what those lines of code do. Is this part of the solution?
再次感谢。
推荐答案
我想否
,你不能使用 Conditional-CSS
作为内联。
I think NO
, You can't use Conditional-CSS
as in-line.
但如果你想根据浏览器指定css风格,这里有一些css-hacks可用:
But If you want to specify css-style according browser, here some css-hacks available:
这篇关于IE和其他的条件内联CSS?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!