我有這樣的例子:http://jsfiddle.net/WkpL9/
HTML:安排字幕上的圖像
<div class="span2">
<div class="image-container">
<img alt="" src="http://placehold.it/150x120"/>
<p>asdadsadasdasdsadasdasdasdasdsadsad</p>
</div>
</div>
CSS:
.image-container {
position: relative;
margin-left: auto;
margin-right: auto;
width: 100%;
}
.image-container img {
max-height: 150px;
}
.image-container p {
white-space: nowrap;
width: 100%;
overflow: hidden;
text-overflow: ellipsis;
position: absolute;
bottom: 0px;
}
我想的圖像的標題爲: 1.定位在圖像(在頂層)。 2.垂直放置在圖像的底部。 3.帶省略號。 4.不會離開包裝div。
這可能嗎?
我正在使用twitter bootstrap。