Unclickable image inside link in IE7

Having a problem with IE7, here is an explanation.

HTML

<a class="item" href="http://google.com">
   <div class="itemImg">
       <img src="http://img-fotki.yandex.ru/get/4512/vmazann.0/0_52db2_1c3135a9_orig.jpg" alt=""/>
   </div>
   <h3>Hello World</h3>
</a>

CSS

.item {
   color: #140804;
   cursor: pointer;
   padding: 17px;
   position: relative;
   text-align: center;
   text-decoration: none;
   width: 142px;
   display:block;}
.item * {
   cursor: pointer;}
.itemImg {
   background: none repeat scroll 0 0 red;
   height: 150px;
   line-height: 150px;
   margin-bottom: 10px;
   overflow: hidden;
   text-align: center;
   vertical-align: middle;}
.itemImg img {
   vertical-align: middle;}

Result

http://jsfiddle.net/qjSpS/11/

Problem

In IE7, the image is unrecoverable

My thoughts on the problem

It seems that the problem is somehow related to setting the hasLayout property to .itemImg. If I remove the properties that cause hasLayout (height: 150 pixels and overflow: hidden;), then the image will be viewable

Question

Is there any way to solve this problem? height: 150 pixels; and overflow: hidden; required properties.

+3
source share
4 answers

Perhaps in IE you cannot wrap an inline element <a>around block level elements <div>or <h3>.

, , IE .

+3

... :

<a><div><img></div></a> 

:

<a href=""><div><div style=background:url(img.jpg);width:10px;height:10px;></div></div></a>

.

+3
if ($.browser.msie  && parseInt($.browser.version, 10) === 7) {
    $('.itemImg').click(function () {
        $(window.location).attr('href', $(this).parent('a').attr('href'));
    });
} 
+1

Source: https://habr.com/ru/post/1796291/


All Articles