【发布时间】:2012-04-13 12:41:35
【问题描述】:
我有一个工作正常的分离器。现在客户想要将拆分器从水平视图更改为垂直视图。我的意思是拆分器首先水平拆分为 2 个 div,当我单击按钮时,它会发生变化,以便垂直拆分相同的 2 个 div。
我试过了
<script type="text/javascript">
$(function () {
$('.LeftPane').attr('id', 'LeftPane');
$('.RightPane').attr('id'`enter code here`, 'RightPane');
$("#MySplitter").splitter({
type: "v"
});
$('#Button1').click(function () {
$('#LeftPane').attr('id', 'TopPane');
$('#RightPane').attr('id', 'BottomPane');
$("#MySplitter").splitter({
type: "h"
});
});
});
</script>
<style type="text/css" media="all">
#MySplitter
{
height: 400px;
width: 600px;
margin: 1em 2em;
background: #def;
border: 2px solid #039; /* No padding allowed */
}
#LeftPane
{
background: #def;
overflow: auto;
width: 200px; /* optional, initial splitbar position */
min-width: 50px;
}
#RightPane
{
background: #def;
overflow: auto;
min-width: 100px; /* No margin or border allowed */
}
#MySplitter .vsplitbar
{
width:8px;
cursor: e-resize; /* in case col-resize isn't supported */
cursor: col-resize;
background-color:Black;
}
#MySplitter .vsplitbar.active, #MySplitter .vsplitbar:hover
{
background-color:Black;
}
#TopPane
{
background: #def;
overflow: auto;
width: 200px;
min-width: 50px; /
}
#BottomPane
{
background: #def;
overflow: auto;
min-width: 100px; /* No margin or border allowed */
}
#MySplitter .hsplitbar
{
height: 2px;
background: #487BA4;
}
#MySplitter .hsplitbar.active, #MySplitter .hsplitbar:hover
{
background: #487BA4;
}
</style>
</head>
<body>
<div id="MySplitter">
<div class="LeftPane">
<p>
This is the left side of the vertical splitter.</p>
</p>
</div>
<div class="RightPane">
This is the right side of the vertical splitter.</p>
</div>
</div>
<p>
<input id="Button1" type="button" value="splitchange" /></p>
</body>
</html>
【问题讨论】:
-
您的示例代码得到了什么样的结果?它以什么方式没有做你想做的事?
-
默认分割器水平分割。当我们点击按钮时,它会垂直分割
-
是的。我知道你想让它做什么。那不是问题。您给了我们一大块示例代码(这很好)。问题是示例代码实际上做了什么。据推测,如果您的示例代码确实做了您希望它做的事情,那么您就不会在这里。
-
不,我的代码不符合我的要求,您只是不需要查看我的代码,只需通过提供示例代码为我提供解决方案,我将非常感谢。
-
再来一次... 如何不符合您的要求?它做了什么?你收到错误了吗?它什么都没做吗?您提供的示例代码实际效果如何?
标签: javascript jquery jquery-ui jquery-plugins