如何在图像中心定义文本 [英] how to define text in center of image

查看:55
本文介绍了如何在图像中心定义文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在用html显示图像和相关图像的标题.
我希望标题位于图像的中心.
我该怎么做?

I am displaying image and heading of related image in html.
I want the heading to be at the center of the image.
How can I do this ?

推荐答案

您可以将图像设置为DIV标签的背景,并将文本放置在DIV中.
如果正确设置CSS,则只需动态更改背景图片即可.
You can set the image as a background of a DIV tag place the text inside the DIV.
If you setup your CSS properly you''ll only need to change the background image dynamically.
#DisplayingImage { display:block; margin:0; padding:0; text-align:center; }
#DisplayingImage SPAN { vertical-align:middle; }


<div id="DisplayingImage" style="background: removed("image.jpg") no-repeat left top transparent;"><span>HEADING TEXT</span></div>


这篇关于如何在图像中心定义文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆