基本的に私がやりたいことは、以下の例を考慮して、複数行のテキスト サイズに応じて流動的で動的な背景幅を作成することです。これは、正当化されたテキストの配置を設定し、ある時点 (たとえば 2 行目) で、テキストが背景の幅全体を埋めていないためです。これは、より大きな上の文によって拡大されます。背景でいっぱいになりたくない!私が自分自身を明確にしているかどうかはわかりませんが、以下の例で説明しようとします.
HTML
<div class="image">
<img src="http://s23.postimg.org/g033nno17/image.jpg">
<div class="title">This is a title</div>
</div>
<div class="image">
<img src="http://s23.postimg.org/g033nno17/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</div>
</div>
CSS
.image {
position: relative;
width: 800px;
height: 530px;
margin: 10px;
}
.title {
position: absolute;
background-color: #CCC;
text-align: justify;
max-width: 600px;
bottom: 30px;
padding: 5px;
}
ご覧のとおり、最後の青い四角にはテキストが 2 行に分かれています。灰色がかった背景は、最初の行に基づいて幅を埋めます。私がやりたいことは、2 行目で、その行のテキストだけが灰色で塗りつぶされることです。
例: http://s9.postimg.org/634pzc9y7/example.jpg
これは可能ですか?すべての応答に事前に感謝します。