基本的に、画像の中にタイトルがあります。以下のコードと例からわかるように、負の margin-top を設定して、画像内の下部近くに配置しました。問題は、テキストの位置/向きが上から下にあることです。つまり、タイトルのテキストが多いほど、下部に向かって長くなります。私はそれを逆にしたい - テキスト div がテキストをそのサイズに応じて上に向かって拡張するようにします。
出来ますか?前もって感謝します。
ここに例がありますhttp://jsfiddle.net/j7gLd/
HTML
<div class="image">
<img src="image.jpg">
<div class="title">This is a title</div>
</div>
<div class="image">
<img src="image.jpg">
<div class="title">This is a title This is a title This is a title This is a title This is a title This is a title This is a title This is a title This is a title This is a title This is a title This is a title This is a title</div>
</div>
CSS
.image {
width: 800px;
height: 530px;
margin: 10px;
}
.title {
position: absolute;
background-color: #CCC;
max-width: 600px;
margin-top: -80px;
padding: 5px;
}