ダイナミックなスライド ショーを作成しています。
ボックス内の中央および垂直方向に整列するために動的に割り当てるテキストを取得しようとしています。
これまでのところ、私は持っています:
HTML
<body>
<div class="slide">
<span class="content">
<b>Hello. This text needs to be:</b><br><br>
- left-aligned but <br>
- centered in the grey box<br>
- even if it changes<br>
- the center of the white box <br>
should equal center of grey one.
</span>
</div>
</body>
CSS
.slide {
position:relative;
background-color: #ddd;
width: 300px;
height: 300px
}
.content {
position: absolute;
top: 30%;
left: 15%;
background-color: #fff;
}
出力
テキストが変更された場合、テキストが中心ではなくなるため、これは機能しません。これを修正する方法はありますか?