需求:将页面水平分割成三部分,比例分别是50%, 25%, 25%
设计步骤:
第一步:下载jqwidget https://www.jqwidgets.com/download/
第二步:将需要的js和css文件(jquery.min.js, jqxcore.js, jqxsplitter.js, jqxbuttons.js, jqxscrollbar.js, jqxpanel.js, demos.js, jqx.base.css )放到自定义的目录下。例如:***/plugins/jqwidgets/
第三步:引入所需的js和css文件,构建html代码如下:
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head >
<link rel="stylesheet" th:href="@{/assets/plugins/jqwidgets/jqx.base.css}" type="text/css"/>
</head>
<body>
<div id='jqxWidget'>
<div id="topSplitter">
<div class="splitter-panel">
panel1
</div>
<div class="splitter-panel">
<div id="bottomSplitter">
<div class="splitter-panel" style="overflow: auto;">
panel2
</div>
<div class="splitter-panel" style="overflow: auto;">
panel3
</div>
</div>
</div>
</div>
</div>
<script>
$(function () {
$('#topSplitter').jqxSplitter({ width: "100%", height: "100%", orientation: 'horizontal', panels: [{ size: "50%" }] });
$('#bottomSplitter').jqxSplitter({ width: '100%', height: '100%', orientation: 'horizontal', panels: [{ size: '50%', collapsible: false }] });
});
</script>
<script type="text/javascript" src="../../scripts/jquery.min.js"></script>
<script th:src="@{/assets/plugins/jqwidgets/jqxcore.js}"></script>
<script th:src="@{/assets/plugins/jqwidgets/jqxsplitter.js}"></script>
<script th:src="@{/assets/plugins/jqwidgets/jqxbuttons.js}"></script>
<script th:src="@{/assets/plugins/jqwidgets/jqxscrollbar.js}"></script>
<script th:src="@{/assets/plugins/jqwidgets/jqxpanel.js}"></script>
<script th:src="@{/assets/plugins/jqwidgets/demos.js}"></script>
</body>
</html>
运行结果如下: