简体   繁体   English

调整HTML容器元素的大小不能正确调整子元素的大小

[英]Resize HTML container element does not correctly resize child elements

I have a simple AngularJS, JS, JQ, HTML5, CSS3 web app. 我有一个简单的AngularJS,JS,JQ,HTML5,CSS3网络应用程序。 I am facing the following problem: when I try to resize the part of web interface - child elements get smaller, but they cross the border line. 我面临以下问题:当我尝试调整Web界面的部分大小时-子元素变小,但它们越过边界线。 All content is grabbed into a <div id="resizable"> which is just jquery-ui resizable element: 所有内容都被捕获到<div id="resizable"> ,这只是jquery-ui resizable元素:

<script> $(function() { $( "#resizable" ).resizable(); }); </script>

It looks like this: 看起来像这样:

1: 1:

在此处输入图片说明

And what I want is that it \\'d be like this: 我想要的是这样:

2: 2:

在此处输入图片说明

No content should be below the border line. 边界线下方不得有任何内容。 What CSS rules have to be applied for child elements so they change their size according to their container element? 必须对子元素应用哪些CSS规则,以便它们根据容器元素更改其大小? I tried already all of available positioning, but it just don't work - elements behave identicaly. 我已经尝试了所有可用的定位,但是它不起作用-元素的行为相同。

Can anyone provide a working plunker, which would be capable of resizing child elements correctly? 任何人都可以提供可以正常调整子元素大小的可工作插件吗? Every useful answer is highly appreciated and evaluated. 每个有用的答案都受到高度赞赏和评估。

Thank you. 谢谢。

Have you tried setting all your heights and widths in % ? 您是否尝试过将所有高度和宽度都设置为% I threw together an example in a JSFiddle, of a 3x3 grid. 我在JSFiddle中提供了一个3x3网格的示例。 They are all set to a 1/3 width and height, and so resize automatically when a user resizes the outer wrap. 它们都设置为宽度和高度的1/3,因此当用户调整外部包装的大小时会自动调整大小。

Example Fiddle 小提琴的例子

HTML HTML

<div class="resizable">
    <div class="row">
        <div class="cell"></div>
        <div class="cell"></div>
        <div class="cell"></div>
    </div>
    ...Two more rows...
</div>

CSS CSS

.row {
    height:33%;
    width:100%;
}
.cell {
    width:33%;
    height:100%;
    float:left;
}

JS JS

$('.resizable').resizable();

Obviously this is an example to demonstrate the concept and not code that will work directly for your site. 显然,这是一个演示概念的示例,而不是直接用于您的站点的代码。 If you could post some of your code, I can try to adapt it. 如果您可以发布一些代码,我可以尝试对其进行调整。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM