请查看以下布局:
<div class="container">
<div class="middleman">
<div class="child">
/* child can grow (height will expand) */
</div>
</div>
</div>
在上述情况下,容器的初始高度为100px
,子的初始高度为70px
。一些动作后,孩子的身高变为300px
。在这种情况下,我怎样才能使容器长高?
答案 0 :(得分:0)
您可以在容器元素上使用$('.child').click(function() {
$(this).toggleClass('height')
})
。
.container,
.middleman {
display: flex;
border: 1px solid black;
padding: 10px;
min-height: 100px;
}
.child {
height: 70px;
border: 1px solid red;
}
.height {
height: 300px;
}
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="container">
<div class="middleman">
<div class="child">
/* child can grow (height will expand) */
</div>
</div>
</div>
&#13;
.btn-donate {
background: #97c83e;
text-align: center;
width: 149px;
height: 149px;
border-radius: 100%;
display: inline-flex;
flex-direction: column;
justify-content: center;
align-items: center;
font-size: 35px;
color: white;
font-weight: bold;
text-decoration: none
}
&#13;