Can you give me advice how to display text over image. Text is variable i can’t workaround it with photoshop ? Image is responsive image is centered and in link bakcground is repeated. Width and height is ok. Thank you very much.
How it should looks like:
How it looks now:
Image repeated on X:
CSS:
a.elipsis{
background: url('showmore-bg.png') repeat-x;
}
HTML:
<a style="display:block; width 100%; margin: 0 auto; text-align: center" class="elipsis" href="#">
show more <!-- text that should be over image -->
<img style="position: relative;" class="cond-arr" src="/css/show_more.png" alt="show_more" />
</a>
4
Answers
I don’t know how much you can change your approach but you could have a div in which you would have your anchor and in CSS you could set the background for that div to be your image and set the dimensions of the div to bew exact the same size as your image.
Check this: http://jsfiddle.net/jHmP7/1/
You just just put your image as a background of your link and wrap it in a div.
You give your link a fixed size, and your wrapper will handle the responsive part.
It would give something like this:
HTML:
CSS:
In case it doesn’t work please provide a jsfiddle so we can work on it.
Maybe it’s not the best solution, but it is the only solution I can get with your current markup. I’ll give absolute positioning to text and relative to link. After that, with jQuery I will calculate position of text, based on width of link and width of whole text.
http://jsfiddle.net/NcxhL/1/
Maybe the following will do what you are looking for.
CSS
HTML
Example