Make a div into a link

后端 未结 27 1656
栀梦
栀梦 2020-11-22 03:15

I have a

block with some fancy visual content that I don\'t want to change. I want to make it a clickable link.

I\'m looking for something l

27条回答
  •  不思量自难忘°
    2020-11-22 04:12

    To make thepeer's answer work in IE 7 and forward, it needs a few tweaks.

    1. IE will not honour z-index if the element is has no background-color, so the link will not overlap parts of the containig div that has content, only the blank parts. To fix this a background is added with opacity 0.

    2. For some reason IE7 and various compatibility modes completely fail when using the span in a link approach. However if the link itself is given the style it works just fine.

    .blockLink  
    {  
        position:absolute;  
        top:0;  
        left: 0;  
        width:100%;  
        height:100%;  
        z-index: 1;  
        background-color:#ffffff;   
        -ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";  
        filter: alpha(opacity=0);  
        opacity:0;  
    }
    

提交回复
热议问题