我想中心文本元素与动态宽度。问题中心对齐动态文本元素与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 2012-02-08 22:55:20