当有预定义的高度时,如何在底部放置文本? [英] How to place text at the bottom when there's predefined height!
问题描述
这应该是令人难以置信的微不足道,但它不是。我有一个锚的预定义高度,我想把文本放在底部。
This should be incredibly trivial, but it's not. I have a predefined height for an anchor, and I would like to place the text at the bottom.
<li><a class="my-text">My Text</a></li>
我使用下面的CSS,不工作。
I used the following CSS, which does not work. The text still appears at the top.
a.my-text {
background-color:#cccc;
height:50px;
vertical-align:bottom;
width:100px;
}
想法是:我想将文本对齐到底部,是长度超过一行的文本,我想让过流流到顶部,而不是推其他任何东西...任何想法如何这可以实现?
The idea is: I want to align text to the bottom, but if there is text that is longer than one line, I want the over flow to go to the top, not push everything else down... any ideas of how this could be achieved?
推荐答案
这不能使用css和你提供的html。如果您在锚点中添加了一个跨度,可以这样做:
This can't be done using css and the html you provide. If you put an extra span in the anchor, it can be done:
a.my-text {
height: 50px;
display: block;
}
a.my-text span {
position: absolute;
bottom: 0;
}
这篇关于当有预定义的高度时,如何在底部放置文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!