我无法确定我的HTML有什么问题,因此jquery-ui-layout
库在浏览器中缩放时(Chrome / Firefox)不想重新计算容器的宽度/高度。在我的HTML中,所有白色窗格都相互连接,但当我缩小时,它们会断开连接......
我查看了官方jquery-ui-layout
演示,例如这个:http://layout.jquery-dev.com/demos/example.html
正如您在Zoom Out元素(它们的内联style
属性)上看到的那样,可以动态地更改它们的值。但是在我的代码中 - 它没有发生 - 值保持不变......
以下是在浏览器中缩小几次时代码在代码中的显示方式:
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-layout/1.4.3/jquery.layout.min.js"></script>
<style>
body { background-color: green; }
.xxx { height: 100vh; }
.left { background-color: red; }
.right { background-color: green; }
.visible-overflow { overflow: visible !important; }
</style>
</head>
<body>
<div class="layout-container visible-overflow">
<div class="xxx ui-layout-center inner-layout left">
<div class="ui-layout-center auto-overflow"></div>
<div class="ui-layout-east"></div>
</div>
<div class="ui-layout-east pane-selector right-side-board-panel right"></div>
</div>
<script>
var element = $('.layout-container');
element.layout({ applyDefaultStyles: true });
element.find('.inner-layout').layout({ applyDefaultStyles: true });
</script>
http://plnkr.co/edit/DhQyktteFfyd5hrKxJQX?p=preview
(要查看问题,请选择在一个单独的窗口中启动预览在plunker中,然后在浏览器中缩小几次)
答案 0 :(得分:3)
你的方法是99.99%正确。你只是错过了height
给layout-container
xxx
我刚修改了以下单行:
.layout-container,.xxx { height: 100vh; }
其余代码非常完美。
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-layout/1.4.3/jquery.layout.min.js"></script>
<style>
body { background-color: green; }
.layout-container,.xxx { height: 100vh; }
.left { background-color: red; }
.right { background-color: green; }
.visible-overflow { overflow: visible !important; }
</style>
</head>
<body>
<div class="layout-container visible-overflow">
<div class="xxx ui-layout-center inner-layout left">
<div class="ui-layout-center auto-overflow"></div>
<div class="ui-layout-east"></div>
</div>
<div class="ui-layout-east pane-selector right-side-board-panel right"></div>
</div>
<script>
var element = $('.layout-container');
element.layout({ applyDefaultStyles: true });
element.find('.inner-layout').layout({ applyDefaultStyles: true });
</script>