動的な幅でテキスト要素を中央に配置しようとしています。CSSで動的テキスト要素を整列させる問題点
HTML:
<div class="healthyrecipes">
<h2>Recipe of the week</h2>
<a href="link"><img src="image" alt="Dip - hommus">
</a>
<span class="recipethisweek">Dip - hommus</span>
</div>
CSS:で
.recipethisweek {
display: inline-block;
float: left;
height: 16px;
left: 30px;
padding: 0 5px;
position: relative;
text-align: center;
top: -20px;
vertical-align: text-top;
width: auto;
}
完全なコードは次のとおりです。http://www.betterhealth.vic.gov.au/
私はスタックオーバーフローで同様の質問に応じたバリエーションのすべての種類を試してみたが、運がない。
ご協力いただければ幸いです。
乾杯、 ベネット
テキストは私にとっては中心的なようですが、どのブラウザを使用しますか? – veritas