Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/90.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/variables/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html CSS表达式_Html_Css_Css Expressions - Fatal编程技术网

Html CSS表达式

Html CSS表达式,html,css,css-expressions,Html,Css,Css Expressions,我在某个地方读到,CSS表达式已被弃用,甚至不应该使用。我从未听说过他们,所以决定去看看。我发现了一个代码示例,它将浮动元素保持在屏幕上的同一位置,即使滚动 <html> <style> #fixed { position:absolute; left:10px; top:expression(body.scrollTop + 50 + "px"); background:white; border:1px solid red;} </style> <b

我在某个地方读到,CSS表达式已被弃用,甚至不应该使用。我从未听说过他们,所以决定去看看。我发现了一个代码示例,它将浮动元素保持在屏幕上的同一位置,即使滚动

<html>
<style>
#fixed {
position:absolute;
left:10px;
top:expression(body.scrollTop + 50 + "px");
background:white;
border:1px solid red;}
</style>
<body>
<p id="fixed">Here is some text, which is fixed.</p>
<p>
[many times: "stuff <br/>"]
</p>
</body>
</html>

#固定的{
位置:绝对位置;
左:10px;
top:表达式(body.scrollTop+50+“px”);
背景:白色;
边框:1px纯红;}

这里有一些文本,它们是固定的

[多次:“stuff
”]

这让我想起了那些在页面底部有“共享栏”之类的东西的网站

所以

  • 他们就是这样做的吗
  • 在这种情况下使用表达式可以吗
  • 如果没有,我应该使用什么
  • 还有什么其他有趣/有用的东西可以用表达式来帮助你吗

  • CSS表达式过去在旧的IE中工作,但它们已经

    Internet Explorer 8及更高版本、IE8标准模式及更高版本不再支持动态属性(也称为“CSS表达式”)。这一决定是出于标准遵从性、浏览器性能和安全原因做出的,如IE博客标题为Ending Expressions的文章所述。Internet Explorer 8中的动态属性在IE7模式或IE5模式下仍然可用

    因此,可以说不值得再学习它们了

    如果没有,我应该使用什么

    根据使用情况,JavaScript或


    正如@另一个极客所指出的,可以使用
    position:fixed
    实现上述示例。IE6不支持这一点-创建CSS表达式可能就是为了解决这个问题。

    要在滚动时将元素保持在相同的位置,您应该使用属性,然后使用top、bottom、left和right属性来告诉它应该放置在何处

    编辑:以下是您的示例的内容:

    <html>
    <style>
    #fixed {
    position:fixed;
    left:10px;
    top: 50px;
    background:white;
    border:1px solid red;}
    </style>
    <body>
    <p id="fixed">Here is some text, which is fixed.</p>
    <p>
    [many times: "stuff <br/>"]
    </p>
    </body>
    </html>
    
    
    #固定的{
    位置:固定;
    左:10px;
    顶部:50px;
    背景:白色;
    边框:1px纯红;}
    

    这里有一些文本,它们是固定的

    [多次:“stuff
    ”]

  • 可能不会。更容易使用
    位置:fixed
    或Javascript
  • 除非你只支持IE<8。IE8+和其他浏览器不支持它*;它不符合标准,无法通过验证
  • 使用
    位置:固定;底部:x;顶部:y;左:a;右:b ;其中x、y、a和b是偏移量。或者,使用Javascript
  • 再说一遍,除非你只使用旧版本的IE。真的,把它扔了。JS和普通CSS也可以达到同样的效果
    *不管怎么说,是官方的。显然,它在@DalexL的Chrome上起了作用。首先,只有IE能理解它们。谷歌Chrome则不然;)代码片段在我的Google Chrome浏览器中运行良好。JavaScript比css表达式灵活得多,无处不在。我们可以使用它们来模拟对旧IE浏览器中css
    表达式
    语法的支持。旧的行为应该是什么?链接到Ending Expressions博客条目: