Forum Moderators: not2easy

Message Too Old, No Replies

Margin and Link Problem

         

almo136

7:26 pm on Jun 11, 2009 (gmt 0)

10+ Year Member



Hi,

I have the below code which shows an image with a link. This works fine in FF but in IE7 the margin is counted as part of the link. ie. If I click somewhere in the left margin it will take me to page1.html

Anyone know how to fix this?

Thanks!

<a class="medialinks" href="http://page1.html"><img src="/images/image1.png" /></a>

.medialinks {
margin-left: 50px;
}

UniverseBoard

9:46 pm on Jun 11, 2009 (gmt 0)

10+ Year Member



not sure about the solution

but you might want to try to put the "class" tag into <img>

almo136

1:10 am on Jun 12, 2009 (gmt 0)

10+ Year Member



Adding the class to the img tag didn't work.

after some more googling I found a site with a few solutions.

I settled for adding:
display: inline-block;

I would link to the page showing the issue and explaining different fixes but not sure if I'm allowed to?

rocknbil

3:44 am on Jun 12, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If I click somewhere in the left margin it will take me to page1.html

Before committing to the inline-block, try this:

.medialinks { border: 1px solid #ff0000; }
.medialinks img { border: 1px solid #00ff00; }
....

<a class="medialinks" href="http://page1.html"><img src="/images/image1.png" /></a>

See if the borders reveal anything about your problem. Is padding somewhere pushing the link beyond where you'd expect it to? Is there some other selector in .medialinks causing it to be wider than the image (or something?) You might be able to fiddle with padding and margins to get it to go away.