Jump to content

Image Links


rarebit

Recommended Posts

Hi,

Simply, i'm wanting to display an image, which is a link, but also has text inside it. The whole thing needs to be the size of the image, but the size is unknown and no javascript allowed.

 

The following does actually do the trick, but i'm after a simpler way...

<div style='position:relative;float:left;'><a href='#'><img src='imgs/block.gif' border='0px' /><span style='position:absolute;left:0px;top:0px;'>Link 1</span></a></div>
<div style='position:relative;float:left;'><a href='#'><img src='imgs/block.gif' border='0px' /><span style='position:absolute;left:0px;top:0px;'>Link 2</span></a></div>
<br />

 

maybe something along the lines of...

<a href='#'><img src='imgs/solved.gif' alt='Test' border='0px' content='Link 3' /></a><br>

But obviously 'content' doesn't work like that...

 

If possible using no div's.

 

 

hmmm... I love asking questions just because in asking them it makes you think...

<a href='#' style='position:relative'><img src='imgs/block.gif' alt='Test' border='0px' style='position:absolute;left:0px;top:0px;z-index:-10;' />Test</a><br>

That might actually do the trick, basically it does, but i'll have to thoroughly test it.

 

But, how do you do it?

Link to comment
Share on other sites

It works, but I can't get the text to center, it appears the problem is the inner div is parented to the a tag and that doesn't get sized until later... or something...

 

 

<a href='#' style='position:relative;'><img src='imgs/block2.gif' alt='' border='1px' style='z-index:-10;' /><div style='position:absolute;left:0px;top:0px;margin:auto auto;width:100%:height:100%;border: 1px solid #7b0118;'>Test</div></a><br>

<br><br>

 

<a href='#' style='position:relative;'><img src='imgs/block.gif' alt='' border='1px' style='z-index:-10;' /><div style='position:absolute;left:0px;top:0px;margin:auto auto;width:100%:height:100%;border: 1px solid #7b0118;'>Test</div></a><br>

or

<a href='#' style='position:relative;'><div style='position:relative;width:100%:height:100%;'><img src='imgs/block.gif' alt='' border='1px' style='z-index:-10;' /><div style='position:absolute;margin:auto auto;border: 1px solid #7b0118;'>Test</div></div></a><br>

 

Things seem to be getting convoluted here, but if I don't have the inner text then the images' alt won't act as link if the image is missing...

<a href='#' style='position:relative'><img src='imgs/missing.gif' alt='Test' border='1px' style='position:absolute;left:0px;top:0px;z-index:-10;' /></a><br>

 

 

? ? ? HOW TO CENTER SOME TEXT WITHIN AN IMAGE, WITHIN A LINK ? ? ?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.