相关疑难解决方法(0)

如何检测DIV的尺寸变化?

我有以下示例html,有一个100%宽度的DIV.它包含一些元素.在执行窗口重新调整大小时,可以重新定位内部元素,并且div的尺寸可以改变.我问是否可以挂钩div的尺寸变化事件?以及如何做到这一点?我目前将回调函数绑定到目标DIV上的jQuery resize事件,但是,没有输出控制台日志,请参见下文:

在调整大小之前 在此输入图像描述

<html>
<head>
    <script type="text/javascript" language="javascript" src="http://code.jquery.com/jquery-1.6.1.min.js"></script>
    <script type="text/javascript" language="javascript">
            $('#test_div').bind('resize', function(){
                console.log('resized');
            });
    </script>
</head>
<body>
    <div id="test_div" style="width: 100%; min-height: 30px; border: 1px dashed pink;">
        <input type="button" value="button 1" />
        <input type="button" value="button 2" />
        <input type="button" value="button 3" />
    </div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

html javascript jquery

314
推荐指数
14
解决办法
32万
查看次数

resize div上的angular2变化检测

我使用bootstrap作为我的布局,我需要检查自动计算的带有引导程序的DIV的大小是否已更改,例如width = 25%.

是否有可能对我未在模板中设置的属性进行更改检测,但是由bootstrap设置.(窗口:调整大小)是不够的.

谢谢

resize angular2-changedetection angular

16
推荐指数
2
解决办法
3万
查看次数