<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <title>42度空间-弹性布局(flexbox) 之 flex-grow测试</title>
    <style>
        .box {
            display: flex;
            border : 1px solid #ccc;
            margin:0.5em 0;
        }
        .item {
            color:#fff;
            background: #000;
            padding: 0.5em 0.2em;
            margin: 0.2em;
            text-align: center;
        }
        .code {
            padding: 2px;
            font-size: 90%;
            color: #c7254e;
            background-color: #f9f2f4;
            border-radius: 4px;
        }
    </style>
</head>
<body>
<div id="wrapper">
    <div class="box">
        <div class="item" id="item1">1 <br /><span id="span1" class="code">flex-grow:0</span> </div>
        <div class="item" id="item2">2 <br /><span id="span2" class="code">flex-grow:0</span> </div>
    </div>
</div>
<script type="text/javascript" src="http://res.42du.cn/vendor/jquery/jquery.min.js"></script>
<script>
    $(document).ready(function () {
        var vals = [[0,0],[0,1],[1,0],[1,1],[1,2],[2,1]];
        var i = 1;
        var stop = false;
        var id = setInterval(function () {
            if(!stop) {
                $("#span1").html("flex-grow:"+vals[i][0]);
                $("#span2").html("flex-grow:"+vals[i][1]);
                $("#item1").css("flex-grow",vals[i][0]);
                $("#item2").css("flex-grow",vals[i][1]);
                i++;
                i = i > 5 ? 0 : i;
            }
        },2000);
        $("#wrapper").click(function () {
            stop = !stop;
        });
    });
</script>
</body>
</html>