jquery - 调整两个 iframe 的大小会失去对鼠标拖动的关注
问题描述
我有两个水平的 iframe(一个在另一个之上)。当我手动调整顶部 iframe 的大小时,另一个会相应地调整大小。
但是当我向下拖动鼠标时,它也不起作用。只有当我拖得很慢时它才有效。不知何故,它失去了对底部 iframe 的关注。我已将底部 iframe 变小,以查看当我将鼠标拖到它的 DIV 上时它工作得很好。
如何使用鼠标向上和向下拖动相同?
试试:http: //jsfiddle.net/ngjp0o1L/
头
<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script type="text/javascript" src="http://code.jquery.com/ui/1.9.2/jquery-ui.js"></script>
<link rel="stylesheet" type="text/css" href="http://code.jquery.com/ui/1.9.2/themes/base/jquery-ui.css">
<style>
#parent {
position: absolute;
height: 90%;
margin: 0;
padding: 0;
width: 95%;
}
#div1 {
position: relative;
height: 50%;
background-color: yellow;
margin-bottom: 10px;
}
#div2 {
position: relative;
height: 50%;
background-color: green;
z-index: 4;
}
</style>
身体
<div id="parent">
<div id="div1"> <iframe id="iframe1" src="http://www.example.com/" style="width:100%; height:100%;"></iframe> </div>
<div id="div2"> <iframe id="iframe2" src="http://www.example.com/" style="width:80%; height:100%;"></iframe> </div>
</div>
<script>
$("#div1").resizable({
start: function (event, ui) {
ui.element.append($("<div/>", {
id: "iframe-barrier",
css: {
position: "absolute",
top: 0,
right: 0,
bottom: 0,
left: 0,
"z-index": 10
}
}));
},
stop: function (event, ui) {
$("#iframe-barrier", ui.element).remove();
},
resize: function (event, ui) {
$("iframe", ui.element).width(ui.size.width).height(ui.size.height);
}
});
$('#div1').resize(function () {
$('#div2').height($("#parent").height() - $("#div1").height());
});
</script>
解决方案
我解决了!附加的 DIV 仅涵盖顶部 iframe/div。我把它做得更大,也覆盖了底部的 iframe/div,它不再失去焦点。
推荐阅读
- html - 这个新的 URL 结构的浏览器解释是什么:/#:~:text=abcd
- php - laravel dd 返回空值
- json - functions/lib/functions/src/index.ts 不存在,无法部署 Cloud Functions
- javascript - 为什么第一次访问 DOM 比较慢
- mysql - 如果间隔不是“满”,如何使 OVER() 中的结果无效
- css - 在 disqus 中切换暗/亮模式
- python - LSTM 预测模式 010101... 了解隐藏状态
- javascript - 如何通过 Id 获取数组元素进行比较?
- typescript - 没有右手边的打字稿映射类型,wtf?
- jquery - 点击时的jQuery标志动画