Javascript 反应动力学

Javascript 反应动力学,javascript,twitter-bootstrap,responsive-design,kineticjs,Javascript,Twitter Bootstrap,Responsive Design,Kineticjs,我正在努力使我的动态JS容器响应。目前这是我的代码 window.onresize = function(event) { //this function will resize your stage to the size of your window stage.setWidth(window.innerWidth); stage.setHeight(window.innerHeight); stage.draw(); //redra

我正在努力使我的动态JS容器响应。目前这是我的代码

    window.onresize = function(event) {  //this function will resize your stage to the size of your window
        stage.setWidth(window.innerWidth);
        stage.setHeight(window.innerHeight);
        stage.draw(); //redraw the stage, not sure if really needed, but good to have.
    }

    var stage = new Kinetic.Stage({
        container: 'gamebox', // Find an HTML element
        width: window.innerWidth, // Set width
        height: window.innerHeight // Set heigth
    });
在使用Bootstrap时,我希望获得div类的宽度,而不是获取浏览器窗口的innerWidth。有可能吗?如果有,你怎么做

编辑: 我最终解决了我的问题,把我的代码改成这个

window.onresize = function(event) {  //this function will resize your stage to the size of your window
    stage.setWidth($('.col-lg-6').width());
    stage.setHeight($('.col-lg-6').height());
    stage.draw(); //redraw the stage, not sure if really needed, but good to have.
}
var stage = new Kinetic.Stage({
    container: 'gamebox', // Find an HTML element
    width: $('.col-lg-6').width(), // Set width
    height: $('.col-lg-6').height() // Set heigth
});

你应该把你的答案放在答案部分,并在stackoverflow允许的时候接受它。干杯