我一直在玩這個片刻,但似乎無法弄清楚如何正確設置它。設置垂直填充家長
鑑於此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