gpt4 book ai didi

javascript - 像 JSFiddle 这样的面板

转载 作者:太空狗 更新时间:2023-10-29 13:29:09 29 4
gpt4 key购买 nike

我有这个,

enter image description here

我要,

enter image description here

Fiddle

当“秒”选项卡上升时,我想降低第一个部分的高度,始终显示最小第一个 2,与第二个部分相同。

$('#second').resizable({
handles: {
'n': '#ngrip',
},
resize: function () {
var b = $('#second').height();
var a = $('#first').css("height", b + "px");
console.log(a.height());
}
});

编辑

必须有 -- 我希望它像 JSFiddle“HTML”和“JavaScript”面板一样工作,它们都可以调整大小,但也有最小高度,如您在此处看到的那样

http://jsfiddle.net/

最佳答案

$('#second').resizable({
handles: {
'n': '#ngrip',
},
maxHeight: 300,
minHeight: 150,
resize: function (event, ui) {
var h = ui.size.height;
$('#first').height(400 -h);
}
});
#main {
width:100%;
height:400px;
overflow: hidden;
position: relative;
}

#first, #second {
height:200px;
width: 100%;
overflow-y: scroll;
}

#second {
z-index:999;
position: absolute;
}

#first-head, #second-head {
background-color:red;
}

#ngrip {
position: relative;
width: 10px;
height: 10px;
background-color: #ffffff;
border: 1px solid #000000;
bottom: -5px;
left: 50%;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script src="http://code.jquery.com/ui/1.8.18/jquery-ui.min.js"></script>
<div id="main">
<div id="first">
<div id="first-head">
<h3>First</h3>
</div>
<div id="first-body">
<p>First-1</p>
<p>First-2</p>
<p>First-3</p>
<p>First-4</p>
<p>First-5</p>
<p>First-6</p>
</div>
</div>
<div id='second'>
<div id="second-head">
<h3>Second</h3>
<div class="ui-resizable-handle ui-resizable-n" id="ngrip"></div>
</div>
<div id="second-body">
<p>Second-1</p>
<p>Second-2</p>
<p>Second-3</p>
<p>Second-4</p>
<p>Second-5</p>
<p>Second-6</p>
</div>
</div>
</div>

使用 JqueryUI 的 minHeightminHeight 选项结合 CSS display: absolute; for #second

首先,更改 HTML 中的调整大小方向(从 ui-resizable-sui-resizable-n)

 <div class="ui-resizable-handle ui-resizable-n" id="ngrip"></div>

其次,在 Javascript 中使用 JqueryUI 选项:

$('#second').resizable({
handles: {
'n': '#ngrip',
},
maxHeight: 300, // Example max height of `#second` is 300px
minHeight: 100, // Example min height of `#second` is 100px
resize: function (event, ui) {
// Get height of `#second`
var h = ui.size.height;

// Set height of `#first`
$('#first').height(400 - h); //400 is height of container `#main`
}
});

最后,改一些CSS

#main {
width:100%;
height:400px;
overflow: hidden;
position: relative;
}

#first, #second {
height:200px;
width: 100%;
overflow-y: scroll;
}

#second {
z-index:999;
position: absolute;
}

#first-head, #second-head {
background-color:red;
}

#ngrip {
position: relative;
width: 10px;
height: 10px;
background-color: #ffffff;
border: 1px solid #000000;
bottom: -5px;
left: 50%;
}

希望对你有帮助。

关于javascript - 像 JSFiddle 这样的面板,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32009295/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com