
<div class="img_wd">
<div class="c_img"><img src="test.jpg" width="100px" height="100px"/></div>
<div class="c_words">测试文字</div>
</div>
<style>
.c_img{position:relative}
.c_words{position:absolutetop:35pxheight:30pxline-height:30px}
</style>
如要文字居中显示:top值=(图片高度-文本div高度)/2
如需要求水平居中:left=(图片宽度-文本div宽度)/2
方案二:用图片做文字图层背景
<div class="img_wd">测试文字</div><style>
.img_wd{
background:url(test.jpg) top center no-repeat
width:100pxheight:100pxline-heiht:100px
text-align:center}
</style>
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)