15 iframe jquery user-interface resize
我有这个代码,它工作正常:
头
<script>
$(document).ready(function()
{
$("#test").resizable({minHeight: 50, minWidth: 50});
});
</script>
Run Code Online (Sandbox Code Playgroud)
身体
<div id="test" style="border: .1em solid black;">
</div>
Run Code Online (Sandbox Code Playgroud)
但是当我将"div"改为"iframe"时,我再也无法调整它了.
身体
<iframe id="test" style="border: .1em solid black;">
</iframe>
Run Code Online (Sandbox Code Playgroud)
Pos*_*ork 15
当一次移动鼠标超过几个像素时,发现redsquare的演示有点不稳定.我已经应用了一些修改,有助于使调整大小更顺畅:
<html>
<head>
<style type="text/css">
#resizable { width: 150px; height: 150px; padding: 0.5em; }
#resizable h3 { text-align: center; margin: 0; }
.ui-resizable-helper { border: 75px solid #EFEFEF; margin: -75px; }
</style>
<script type="text/javascript">
$(function() {
$("#resizable").resizable({
helper: "ui-resizable-helper"
});
});
</script>
</head>
<body>
<div class="demo">
<div id="resizable" class="ui-widget-content">
<iframe src="http://pastebin.me/f9ed9b9d36d17a7987e9cb670e01f0e2" class="ui-widget-content" frameborder="no" id="test" width="100%" height="100%" />
</div>
<div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
调整大小的奇怪之处似乎发生,因为mousemove事件不会从iframe中冒出来.只要浏览器能够跟上mousemove事件,在处理程序CSS中使用调整大小处理程序和大边框可以最大限度地减少iframe造成的影响.
以下代码为我工作顺利.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>jQuery UI Resizable - Default functionality</title>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<style>
#iframe {
width: 100%;
height: 100%;
border: none;
background: #eee ;
z-index: 1;
}
#resizable {
width: 100px;
height: 100px;
background: #fff;
border: 1px solid #ccc;
z-index: 9;
}
</style>
<script>
$(function() {
$('#resizable').resizable({
start: function(event, ui) {
$('iframe').css('pointer-events','none');
},
stop: function(event, ui) {
$('iframe').css('pointer-events','auto');
}
});
});
</script>
</head>
<body>
<div id="resizable">
<iframe src="test.html" id="iframe">
</div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
32421 次 |
| 最近记录: |