简体   繁体   English

删除内部div时正确调整外部div

[英]correctly adjust the outer div when the inner div is deleted

Let's say currently I have an outer div containing which contains 5 inner divs. 假设当前我有一个包含5个内部div的外部div。 And the outer div has a max-width and therefore it only contains at most 4 divs horizontally. 而且外部div具有最大宽度,因此水平最多只能包含4个div。 Eg: |d1 d2 d3 d4| 例如:| d1 d2 d3 d4 | |d5 | D5

I also make a 'close' button on the inner div, so if I close one, the div would be deleted. 我还在内部div上做了一个“关闭”按钮,所以如果我关闭一个,该div将被删除。

HERE IS THE PROBLEM: If I delete d4, sometimes the outer div would display |d1 d2 d3 d5|, THIS IS WHAT I WANT but sometimes the outer div's width shrinks a little bit and displays |d1 d2 d3 | 这里是问题:如果删除d4,有时外部div会显示| d1 d2 d3 d5 |,这就是我想要的,但有时外部div的宽度会缩小一点并显示| d1 d2 d3 | |d5 | | d5 |

Does anyone know why is it like this? 有人知道为什么会这样吗?

在外部div上添加一个min-width属性,以防止其进一步缩小。

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

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