我一直在玩这个片刻,但似乎无法弄清楚如何正确设置它。设置垂直填充家长
鉴于此HTML:
<div class="item-container bottom-spacer">
<div id="my-friends"><div id="2" class="user-profile-card">
<img src="">
<div><h3>John</h3></div>
<h3>Details</h3><br>
Date: Tuesday, June 24th 2014, 11:47 am<br>
Val1: 22<br>
Val2: 28<br>
<div>
<h3>Notes</h3><br>
Just some notes...
</div>
<div class="user-profile-li-buttons"><button class="delete-button" onclick="friendsPage.deleteFriend(2)">X</button></div>
</div><div id="4" class="user-profile-card">
<img src="">
<div><h3>Mr User One</h3></div>
<h3>Details</h3><br>
<div>
<h3>Notes</h3><br>
Just some notes...
</div>
<div class="user-profile-li-buttons"><button class="delete-button" onclick="friendsPage.deleteFriend(4)">X</button></div>
</div><div id="6" class="user-profile-card">
<img src="">
<div><h3>Mr User Two</h3></div>
<h3>Details</h3><br>
Date: Tuesday, June 24th 2014, 6:30 pm<br>
Val1: 31<br>
Val2: 20<br>
<div>
<h3>Notes</h3><br>
Just some notes...
</div>
<div class="user-profile-li-buttons"><button class="delete-button" onclick="friendsPage.deleteFriend(6)">X</button></div>
</div></div>
<div class="clear-fix"></div>
</div>
和一些CSS:
.item-container {
padding: 20px;
border: 0 #fff solid;
background: #ccc;
box-sizing: border-box;
-ms-box-sizing: border-box;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
border-radius: 0.3ex;
-webkit-border-radius: 0.3ex;
-moz-border-radius: 0.3ex;
overflow: auto;
height:100%;
}
#my-friends {
height: inherit;
}
.user-profile-card {
overflow: hidden;
background: #333;
color: #fff;
border-radius: 0.3ex;
-webkit-border-radius: 0.3ex;
-moz-border-radius: 0.3ex;
margin: 5px;
float: left;
font-size: 0.8em;
width: 160px;
padding: 5px;
height: 100%;
}
我本来以为这是因为我是动态地添加HTML内容与jQuery,但已经建立了一个的jsfiddle似乎后我也错了。
如何让这些内部div正确垂直拉伸填充父div?
的小提琴是在这里:
不知道这是你的意思,但你有没有尝试添加'明确:两者;'在CSS'。用户瞩目,card'?你可以添加'margin:5px auto;'来居中它们。 – invot
“正确垂直拉伸”是什么意思?你想要每个'.user-profile-card'来填充窗口的高度? – showdev
这不起作用,它将它们堆叠在彼此之上而不是并排。 – Jammer