mscommunity.net

Interactive mscommunity.net online activities
Signed in as anonymous | Edit Profile | Sign out | Help
in Search

Weblog :: Boris Ševo

Sporadic posts about my interests, e.g. software development (mostly .NET), technology in general and some occasional rant.

Anchor is not clickable in Firefox and Safari when it's inside of the div tag which has image as background

That's one of mine older issues which I was facing few months ago and today, while I was browsing through my pending blog posts, I decided to post few words about it hoping that it will save you few minutes of work if you ran into the same problem as I was.

So, let's imagine that you want to put some link (anchor tag) inside a div tag which has some image as a background and that your link need to positioned somewhere inside of the image (div's background). Your HTML code will then be something like this:

<div class="divsCSSClass">
    <a href="Default.aspx" style="left: 133px; position:relative; top: 7px;">
some_text
</a>
</div>

and your CSS will then be something like this:

.divsCSSClass {
     background: url('image_name.png');
     width:392px;
     height:45px;
}

Above code will work in IE and Opera, but in Firefox and Safari link (anchor) will not be clickable. The solution is extremely simple. All you need to do is to add position:relative; to div's CSS class. CSS will then be something like this:

 .divsCSSClass {
     background: url('image_name.png');
     width:392px;
     height:45px;
     position: relative;
}
Published pro 11 2008, 04:05 by boris.sevo
Filed under: ,

Comments

 

anonymous said:

Hey... solution was very simple but most effective in this situation... i have been working on this issue from last 2 days...but no success... and this two word style change made my life easier... Thanks alot buddy...

veljača 24, 2009 8:50
 

anonymous said:

hi friend i have the same issue that i hav a div with background image and inside that there is a Anchor tag it works in all browsers except IE6..

in iE6 the link is not clickble.....

help me if u can

email-abhiavs1987@gmail.com

THANKS...........

;)

listopad 9, 2009 9:44
 

anonymous said:

FANTASTIC!!!!! Struggled with this stupid unclickable links for days. Your solution worked like a charm. Thank you Thank you Thank you!

prosinac 7, 2009 3:16
 

boris.sevo said:

Cool. I'm glad I could help you.

prosinac 7, 2009 11:22

Leave a Comment

(required) 
(optional)
(required) 
Submit
Powered by Community Server (Commercial Edition), by Telligent Systems