各种calc()polyfill库在IE8中不起作用

时间:2014-07-03 23:52:34

标签: javascript css css3 internet-explorer-8 polyfills

我被要求创建一个带有标题和侧边栏的页面,其中侧边栏是页面高度的100%减去标题高度,没有垂直滚动条。以下适用于FF,Chrome和IE9 +,但polyfill在IE8中不起作用。

我在IE8中尝试过以下2个polyfill calc库,但都不起作用。我做错了什么,或者图书馆在给定的场景中不起作用?我已经尝试按照示例使用Modernizr加载脚本,以及直接在页面末尾加载脚本而不起作用。

代码示例:

<!DOCTYPE html>
<html>
    <head>
        <title>title</title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js"></script>
        <script type="text/javascript" src="modernizr.custom.js"></script>
        <style>
            body,html{
                height: 100%;
                color: white;
                margin:0;
                padding: 0;
            }
            .heading{
                background:red;
                height: 100px;
            }
            .box{
                background: blue;
                width:200px;
                height: 100%;
                height: calc(100% - 100px);
            }

        </style>

    </head>
    <body>
        <div class="heading">Heading</div>
        <div class="box">Sidebar</div>

        <!--MUST be placed after styles have loaded-->
        <!--<script type="text/javascript" src="./calc.min.js"></script>-->
        <!--<script type="text/javascript" src="./polycalc.js"></script>-->
        <script>
            jQuery(document).ready(function() {
            });
                    Modernizr.load({
                    test: Modernizr.csscalc,
//                    nope: 'calc.js'
                    nope: 'polycalc.js'
                });
        </script>
    </body>
</html>

1 个答案:

答案 0 :(得分:3)

CJKay Polycalc需要CSSParser库才能工作。这适用于IE7 +。

<!--CSSParser required for CJKay Polycalc
    https://github.com/Schepp/CSS-Filters-Polyfill
    copy following files to: js/css_parser
    - contentloaded.js
    - css-filters-polyfill-parser.js
    - css-filters-polyfill.js
    - cssParser.js
-->
<script>
    var polyfilter_scriptpath = "js/css_parser/";
</script>
<script type="text/javascript" src="js/css_parser/cssParser.js"></script>

<!--
    CJKay Polycalc
    https://codeload.github.com/CJKay/PolyCalc/zip/master
-->
<script type="text/javascript" src="js/polyfill/cjkay-polycalc.js"></script>