Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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 ?
Posted
v2
Comments
Sergey Alexandrovich Kryukov 30-Jul-12 12:20pm    
Do you want to embed some text in the image by its center, or to put some text element over the image?
--SA

1 solution

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.
CSS
#DisplayingImage { display:block; margin:0; padding:0; text-align:center; }
#DisplayingImage SPAN { vertical-align:middle; }

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

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900