好的,所以我有一個元素在元素.item
內,如here所示。現在我想要的是.price
水平居中,並被推/拉到其父母的底部邊界like so。CSS - 水平居中並用純css向下推一個元素
現在,這裏是有趣的部分,這使得這款硬盤:
- 純CSS(不使用Javascript/jQuery的)
- 它需要是動態的,所以
.price
的width
/height
屬性可以波動(見片段)
這是我在多大程度上得到:
.item {
width: 200px;
height: 400px; /* not static */
background: wheat;
}
.product-image {
margin: 0 auto;
width: 180px;
height: 300px;
background: lightskyblue;
}
.price {
margin: 0 auto;
width: 50px; /* not static */
height: 20px; /* not static */
background: indianred;
}
<div class="item">
<div class="product-image">
</div>
<div class="price">
</div>
</div>
在此先感謝。
其實這個修復元素在該項目DIV中不能抵消底部。 –